Re: XmlSerialization is failing due to a circular reference.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Jeremy,

XML serialization does not support circular references. This means that
one of the objects that you are trying to serialize holds onto another
object higher up in the object chain, which in turn causes your circular
reference. You need to make it so that the object does not reference itself
(directly or indirectly) and then the problem should go away.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Jeremy Kitchen" <J.t.Kitchen@xxxxxxxxx> wrote in message
news:1178302946.478954.243220@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have inherited a project and I am trying to figure out why the
failing units tests that exist fail. I a, getting the following error
when I attempt serialization.

Any advice on what I should do to find the source of the problem would
be appreciated.

Thank you
Jeremy

Error 1 TestCase
'SuccessAssessBusiness.SuccessAssessBusinessTest.LinkedAssessments'
failed: System.InvalidOperationException : There was an error
generating the XML document.
----> System.InvalidOperationException : A circular reference was
detected while serializing an object of type
SuccessAssessBusiness.ManagementGroup.
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter
xmlWriter, Object o, XmlSerializerNamespaces namespaces, String
encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter
xmlWriter, Object o, XmlSerializerNamespaces namespaces, String
encodingStyle)
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter
xmlWriter, Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter
textWriter, Object o, XmlSerializerNamespaces namespaces)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter
textWriter, Object o)
at
SuccessAssessBusiness.SuccessAssessBusinessTest.LinkedAssessments() in
C:\Inetpub\wwwroot\SuccessAssess\Projects\SuccessAssess
\SuccessAssessTest\SuccessAssessBusinessTest.cs:line 372
--InvalidOperationException
at
System.Xml.Serialization.XmlSerializationWriter.WriteStartElement(String
name, String ns, Object o, Boolean writePrefixed,
XmlSerializerNamespaces xmlns)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterAssessment.Write8_ManagementGroup(String
n, String ns, ManagementGroup o, Boolean isNullable, Boolean needType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterAssessment.Write9_Jobsite(String
n, String ns, Jobsite o, Boolean isNullable, Boolean needType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterAssessment.Write8_ManagementGroup(String
n, String ns, ManagementGroup o, Boolean isNullable, Boolean needType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterAssessment.Write9_Jobsite(String
n, String ns, Jobsite o, Boolean isNullable, Boolean needType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterAssessment.Write12_Assessment(String
n, String ns, Assessment o, Boolean isNullable, Boolean needType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterAssessment.Write13_Assessment(Object
o) C:\Inetpub\wwwroot\SuccessAssess\Projects\SuccessAssess
\SuccessAssessTest\SuccessAssessBusinessTest.cs 372



.



Relevant Pages

  • XmlSerialization is failing due to a circular reference.
    ... xmlWriter, Object o, XmlSerializerNamespaces namespaces, String ... n, String ns, ManagementGroup o, Boolean isNullable, Boolean needType) ...
    (microsoft.public.dotnet.languages.csharp)
  • XmlSerialization is failing due to a circular reference.
    ... xmlWriter, Object o, XmlSerializerNamespaces namespaces, String ... n, String ns, ManagementGroup o, Boolean isNullable, Boolean needType) ...
    (microsoft.public.dotnet.languages.csharp)
  • Connecting to Sharepoint Problem
    ... String bstrCurrentFolderUrl, Boolean& pbCanCustomizePages, Boolean& ... pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, ... pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& ...
    (microsoft.public.biztalk.general)
  • Re: Connecting to Sharepoint Problem
    ... String bstrCurrentFolderUrl, Boolean& pbCanCustomizePages, Boolean& ... pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, ... pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& ...
    (microsoft.public.biztalk.general)
  • RE: installation WSS 3.0
    ... <exception, Boolean breakConnection) ... <owningObject, SqlConnectionString connectionOptions, String newPassword, ... <newDatabaseId, String strDatabaseServer, String strDatabaseName, String ... <databaseServer, String databaseName, String databaseUsername, String ...
    (microsoft.public.windows.server.sbs)