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 ,.