views:

347

answers:

1

I'm using Visual Web Developer to build a Silverlight Class Library. I have another project where the Class Library is imported and implemented. It's loading an XML file and I'm using XmlSerializer.Deserialize into a class I created with xsd.exe.

Sometimes, when loading the XML, I get this error:

Unhandled Error in Silverlight 2 Application 
Code: 4004    
Category: ManagedRuntimeError       
Message: System.InvalidOperationException: There is an error in XML document (149, 10). ---> System.NotSupportedException: XLinq
   at System.Xml.Serialization.XmlSerializationReader.ReadXmlNodes(Boolean elementCanBeType)
   at System.Xml.Serialization.XmlSerializationReader.ReadTypedPrimitive(XmlQualifiedName type, Boolean elementCanBeType)
   at System.Xml.Serialization.XmlSerializationReader.ReadTypedPrimitive(XmlQualifiedName type)

I've discovered that it only occurs when there is a tag called Extensions in my XML file. At first I thought this was improperly defined in the C# class generated by xsd.exe, but it works if I change Extensions to any other name. Unfortunately, simply changing the name of this tag permanently is not an option. I've ruled out reserved words. Google has no info on this error.

+1  A: 

That's pretty weird. The stack trace you put up appears to be impossible. If you examine the 2.0 Silverlight version of System.Xml.dll, you'll notice that there is no class called XmlSerializationReader. This class is only present in the full framework version of System.Xml.dll.

Did you attempt to deploy the framework version of System.Xml.dll? Or are you using a different library that I'm missing to get access to that class?

JaredPar
XmlSerializationReader is in the System.Xml.Serialization class.
nerdabilly
@nerdabilly, how are you verifying that though? I deleted all of the DLL's from reflector, and then explicitly loaded the System.Xml.dll from the Silverlight directory and it does not contain that class.
JaredPar
@JaredPar, you need to add a reference to the System.Xml.Serialization.dll Library also. It should be in the Silverlight directory.
nerdabilly
@nerdabilly, must be a part of the SDK (only have the runtime on my machine). I'll get that installed and try it out.
JaredPar