5

我们目前在使用我们的 Windows Azure 应用程序时遇到以下错误(来自日志):

System.Runtime.Serialization.SerializationException Assembly 'EntityFrameworkDynamicProxies-Marriott.emergePortal.Common,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not found.

这个错误来来去去,我们无法准确理解是什么原因造成的。

我们已经尝试了一切!任何人都可以提供的任何帮助都会很棒。

日志中的整个错误消息是:

    System.Web.HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown. ---> System.Runtime.Serialization.SerializatioFnException: Assembly 'EntityFrameworkDynamicProxies-Marriott.emergePortal.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not found.
   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
   at ReadArrayOfPropertyEnrollmentFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )
   at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
   at ReadArrayOfPropertyEnrollmentFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
   at ReadArrayOfanyTypeFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )
   at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
   at ReadSerializableSessionStateStoreDataFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)
   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, String name, String ns)
   at System.Runtime.Serialization.NetDataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader)
   at Microsoft.ApplicationServer.Caching.NetDataContractCacheObjectSerializer.Deserialize(Stream stream)
   at Microsoft.ApplicationServer.Caching.DataCacheObjectSerializationProvider.DeserializeUserObject(Byte[][] serializedData, ValueFlagsVersion flagsType)
   at Microsoft.ApplicationServer.Caching.SocketClientProtocol.GetAndLock(String key, TimeSpan timeout, DataCacheLockHandle& lockHandle, String region, Boolean lockKey, IMonitoringListener listener)
   at Microsoft.ApplicationServer.Caching.DataCache.<>c__DisplayClass8a.<GetAndLock>b__89()
   at Microsoft.ApplicationServer.Caching.DataCache.GetAndLock(String key, TimeSpan timeout, DataCacheLockHandle& lockHandle)
   at Microsoft.Web.DistributedCache.DataCacheForwarderBase.<>c__DisplayClass31`1.<PerformCacheOperation>b__30()
   at Microsoft.Web.DistributedCache.DataCacheRetryWrapper.PerformCacheOperation(Action action)
   at Microsoft.Web.DistributedCache.DataCacheForwarderBase.GetAndLock(String key, TimeSpan timeout, DataCacheLockHandle& lockHandle)
   at Microsoft.Web.DistributedCache.BlobBasedSessionStoreProvider.GetItem(HttpContextBase context, String id, Boolean acquireWriteLock, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions)
   at Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions)
   at System.Web.SessionState.SessionStateModule.GetSessionStateItem()
   at System.Web.SessionState.SessionStateModule.PollLockedSessionCallback(Object state)
   at System.Web.SessionState.SessionStateModule.EndAcquireState(IAsyncResult ar)
   at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)
4

1 回答 1

2

在没有看到任何代码的情况下,很难进行故障排除。但是,我们遇到了类似的情况,因为 DataContractSerializer 需要一个特定的类型(如服务接口中定义的那样),但却获得了一个 EntityFramework 代理类型。

我们决定使用数据传输对象模式来解决这个问题。我们创建了作为简单数据传输对象的基类。EF 感知类继承自这些并添加与持久性相关的逻辑。

这些 DTO 对象实现了 ICloneable(或类似的东西),它允许我们在将对象发送到服务级别的序列化程序之前轻松创建实体框架代理类的数据传输副本。

也可以通过创建具有实体框架代理类知识的自定义序列化程序来解决此问题,但这种方法似乎更像是一种 hack。DTO 模式看起来更简单并且非常有效。

于 2013-06-14T18:25:12.530 回答