Pastebin PRO Accounts SUMMER. The entity or complex type 'Models.MenuItem' cannot be. Object graph for type 'WcfServiceLibrary1.ProductVendor' contains cycles and cannot be serialized if reference tracking is disabled.'. Object graph for type X contains cycles and cannot be serialized if reference tracking. Object graph for type 'Microsoft. Xrm. Sdk. Related Entity. Collection' contains cycles and cannot be serialized if reference tracking is disabled. When I write a post update plug- in for entity AIn plug- in i changes some entity attribute's value and call Xrm. Service. Context. Many- to- many relationships & Object graph cycles. Suppose you have three tables in your database where one of them specifies a many- to- many relationship between the other two (example from Adventure. Works): Suppose also that you have a method such as Get. Vendors(int product.
ID) that will retrieve all the vendors for a given product through the Product. Vendors table (that is , the many- to- many table). Now, if this method is exposed via a WCF service, when your client calls it you will see an exception like this one: . An error occurred while receiving the HTTP response to http: //localhost: 8. Design. This could be due to the service endpoint binding not using the HTTP protocol. DataContract Serializer and. WCF cyclic references support. X.Y.Z' contains cycles and cannot be serialized if reference tracking is disabled. EF POCO objects serialized over WCF. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. This is a seralization problem (yes, the exception message is not that clear). To test the serialization of your data I recommend the following test (from here): Service. Service. 1(). List< Vendor> lv = svc. Get. Vendors(3. 19). The problem is that the Vendor object contains a reference to the one or more Product objects (linked through the Product. Vendor table) which contain a reference to one or more Vendors which contain references to Prodcuts and so on .. An infinite cycle of references is being created. WCF does not realize that these references point to the same object and it serializes each reference (eventually throwing an exception). There is a great post (http: //blogs. WCF. But if you are looking for a less complicated solution you can just open the *. Properties' and choose 'Seralization Mode' = 'Unidirectional'. Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Object graph for type contains cycles and cannot be serialized if reference tracking is disabled. Type can't be serialized. As the name indicates, serialization only goes in one direction: from a product to a vendor but not back to products (or from a vendor to a product but not back to products). Without unidirectional serialization you could do this: Vendor.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2016
Categories |