運行契約序列化錯誤在我的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
這使我得出以下結論 - 我必須爲了啓用代理的創建我的應用程序工作,同時我可能會爲我的服務做錯事。有沒有人有任何建議,我可以改變,讓事情工作?