【问题标题】:InvalidCastException in Apache Ignite with ConcurrentDictionaryApache Ignite 中的 InvalidCastException 与 ConcurrentDictionary
【发布时间】:2019-02-27 20:26:37
【问题描述】:

我有一个具有 ConcurrentDictionary 字段的对象。 在访问 Ignite 共享内存中的数据时,出现以下错误。

System.InvalidCastException: [A]System.Collections.Concurrent.ConcurrentDictionary'2[System.String,CampaignEngine.Model.LookupItem] cannot be cast to [B]System.Collections.Concurrent.ConcurrentDictionary'2[System.String,CampaignEngine.Model.LookupItem]. Type A originates from 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' in the context 'Default' at location 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.2.2\System.Private.CoreLib.dll'. Type B originates from 'System.Collections.Concurrent, Version=4.0.14.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in the context 'Default' at location 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.2.2\System.Collections.Concurrent.dll
at Apache.Ignite.Core.Impl.Binary.BinaryReflectiveSerializerInternal.Apache.Ignite.Core.Impl.Binary.IBinarySerializerInternal.ReadBinary[T](BinaryReader reader, IBinaryTypeDescriptor desc, Int32 pos, Type typeOverride)
 at Apache.Ignite.Core.Impl.Binary.BinaryReader.ReadFullObject[T](Int32 pos, Type typeOverride)
 at Apache.Ignite.Core.Impl.Binary.BinaryReader.TryDeserialize[T](T& res, Type typeOverride)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.Deserialize[T](Type typeOverride)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.ReadObject[T](String fieldName)
at lambda_method(Closure , Object , IBinaryReader )
at Apache.Ignite.Core.Impl.Binary.BinaryReflectiveSerializerInternal.Apache.Ignite.Core.Impl.Binary.IBinarySerializerInternal.ReadBinary[T](BinaryReader reader, IBinaryTypeDescriptor desc, Int32 pos, Type typeOverride)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.ReadFullObject[T](Int32 pos, Type typeOverride)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.TryDeserialize[T](T& res, Type typeOverride)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.Deserialize[T](Type typeOverride)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.ReadBinaryObject[T](Boolean doDetach)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.TryDeserialize[T](T& res, Type typeOverride)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.Deserialize[T](Type typeOverride)
at Apache.Ignite.Core.Impl.Binary.Marshaller.Unmarshal[T](IBinaryStream stream, Boolean keepBinary)
at Apache.Ignite.Core.Impl.PlatformJniTarget.InStreamOutLong[TR](Int32 type, Action'1 outAction, Func'3 inAction, Func'2 readErrorAction)
at Apache.Ignite.Core.Impl.Cache.CacheImpl'2.Get(TK key)
at Apache.Ignite.Core.Impl.Cache.CacheImpl'2.get_Item(TK key)

为什么 Ignite 不能反序列化 ConcurrentDictionary?

谢谢...

【问题讨论】:

  • 你好;谢谢你的评论;正如您的共享链接所说, ConcurrentDictionary 不是可序列化的类型。我将所有 ConcurrentDictionary 对象更改为 Dictionary 对象,我将自己处理并发。 (大部分操作都会被读取,所以我不会有太大问题)祝你有美好的一天......

标签: asp.net-core ignite


【解决方案1】:

您的代码中似乎存在导入问题,可能是由于Why is Visual Studio telling me I need to reference System.Private.CoreLib?

检查您的任何源文件以引用 System.Private.CoreLib 并将其替换为 System.Collections.Concurrent

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-02
    • 2016-02-29
    • 2018-10-04
    • 1970-01-01
    • 1970-01-01
    • 2021-09-22
    • 2023-02-21
    • 2020-04-05
    相关资源
    最近更新 更多