This article originates from: http://www.cnblogs.com/zhhh/archive/2011/04/06/2006868.html
A circular reference is detected when a data object is serialized using LINQ to SQL and a System.InvalidOperationException exception is reported, and an object of the type is serialized.
Exception information (partial):
System.Web.Services.Protocols.SoapException: The server was unable to process the request. ---> System.InvalidOperationException: An error occurred while generating the XML document. ---> System.InvalidOperationException: A circular reference is detected when serializing an object of type Web.DAL.Friends.
(slightly later)
This means that when using LINQ to SQL, there is an association between the table and the table, which produces an infinite cyclic reference when serializing these related data objects.
Here we can fix this problem by configuring the DataContext file.
First we open the DataContext file, set the "Serialization mode" property to "single" in the file's Properties window,
Then in the view of the DataContext file, select the relationship between the table and the table, and set the properties of the relationship. In the Properties window, set the value of the access permission property under the parent Properties node to internal.