Cannot Be Serialized If Reference Tracking Is Disabled Rating: 6,5/10 5452 votes

Here are 2 solutions

Solution #1:

I had this same problem and so I decorated my class with DataContract and the members with DataMember like you mention. HOWEVER, I don't like editing auto-generated code directly because I have to redo it every time I regenerate the file. In order to get around this, I used the MetadataType attribute. In your case, it would look like this..

Macpar deluxe free download mac. First, you will keep the auto generated entity as is:

Eso weapon swap pc

Next, in another file, you will create another partial class and decorate it like this:

On 'WCF cyclic references support'. I do have a couple of questions for you if you do not mind. Could it be simply me or do a few of these comments appear like they are left by brain dead individuals?:-P And, if you are posting on additional online social sites, I'd like to follow you.

MetadataType will essentially add the attributes from the Metadata buddy class to the ones with the same name in Comment (not directly, but for our purposes, it's close enough.. that's a topic for a different post). Of course, if your Comment entity changes, you'll need to update this accordingly.

Solution #2:

Having to edit your second file every time you make a change is only a slight improvement from directly editing auto-generated files. Fortunately, there is another approach that is much easier to maintain. Details can be found here but as a summary, all you need to do is decorate your OperationContract that is consuming Comment with an additional attribute, ReferencePreservingDataContractFormat. Note that there is a slight error in the code provided on that page that would cause infinite recursion. As noted in this post, the fix is quite simple: instead of recursing at all, just create a new DataContractSerializer

The advantage to this approach is that no matter how much you change Comment, you still don't need update anything.

Cannot be serialized if reference tracking is disabled one

As an example for your code, let's say you are using Comment as follows:

All you need to do is add

And then somewhere else you need to define ReferencePreservingDataContractFormat which will look like this:

And that's it!

Either method will work just fine--pick the one that works for you.

appbee.netlify.app© 2020