System. invalidoperationexception is reported when a data object is serialized using LINQ to SQL. circular reference is detected when the object of the serialization Type XXX.

Source: Internet
Author: User

System. invalidoperationexception is reported when a data object is serialized using LINQ to SQL. circular reference is detected when a serialized object is serialized.

Exception information (Part ):

System. Web. Services. Protocols. soapexception: the server cannot process the request. ---> System. invalidoperationexception: An error occurred while generating the XML document. ---> System. invalidoperationexception: Circular references are detected when the web. Dal. Friends object is serialized.

(Omitted later)

This means that a table is associated with a table when using LINQ to SQL. When serializing these related data objects, an infinite loop of reference is generated.

Here we can solve this problem by configuring the datacontext file.

First, open the datacontext file and set the "serialization mode" attribute to "single item" in the Properties window of the file ",

 

Select the relationship between the table and the table in the view of the datacontext file, and set the attribute of the relationship. In the "properties" window, set the "access permission" attribute value under the "parent attribute" node to "internal ,.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.