运行契约序列化错误在我的C#应用程序中,我试图通过中间DLL发送请求以将数据添加到QuickBooks。中间DLL基于设置,通过WCF服务发送项添加请求。该服务项目正在使用“操作合同”来管理其中的所有方法。它没有任何数据合同/数据成员。使用Entity Framework 6.0和WCF
此作品适用于发票和其他交易。然而,加入项目时,我收到此错误:
A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in System.Runtime.Serialization.dll
Additional information: Type 'System.Data.Entity.DynamicProxies.QBLookUp_A96F53AD8DA6F21651FEF0B25078616AB4989DA745EE06E345D365196574CE0F' with data contract name 'QBLookUp_A96F53AD8DA6F21651FEF0B25078616AB4989DA745EE06E345D365196574CE0F: http://schemas.datacontract.org/2004/07/System.Data.Entity.DynamicProxies ' is not expected. Consider using a DataContractResolver if you are using DataContractSerializer or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to the serializer.
放眼望去这里对堆栈溢出,我遇到了几个线程建议关闭代理的创建在我的EF模型来解决这个问题。所以我插入这段代码到构造函数在我的EF项目:
this.Configuration.ProxyCreationEnabled = false;
然而,当我关掉代理的创建,我碰上了两个新问题:
A)各种数据的不出现在我的C#应用程序中。这些数据由实体框架提供给应用程序。
B)我收到尝试通过WCF服务,以保存该项目时,这个错误:
Additional information: Object graph for type 'System.Collections.Generic.HashSet`1[[EFModel.Item, EFModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' contains cycles and cannot be serialized if reference tracking is disabled
这使我得出以下结论 - 我必须为了启用代理的创建我的应用程序工作,同时我可能会为我的服务做错事。有没有人有任何建议,我可以改变,让事情工作?