【发布时间】: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