I am trying to use XmlSerializer to serialize the XML string into an object.
I used the XML schema definition to generate the code for the corresponding class (using xsd.exe).
The top level class has references to objects of other classes that are defined in the same schema.
I am trying to deserialize the XML string into an object of the class that was generated as explained above.
Here is my code:
XML string is in this.textBox1.Text.
private void button1_Click(object sender, System.EventArgs e)
{
string strReqInstance = this.textBox1.Text;
XmlTextReader reqInstanceReader = new XmlTextReader(new StringReader(strReqInstance));
XmlSerializer instSerializer = new XmlSerializer(typeof(request_instance));
request_instance reqInstance;
reqInstance = (request_instance) instSerializer.Deserialize(reqInstanceReader);
}
When this code is run I am getting an exception on XmlSerializer construction line:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: File or assembly name a2chdxob.dll, or one of its dependencies, was not found.
If I run the similar code within a web service here is the whole callstack (XML is passed through strReqInstance):
System.IO.FileNotFoundException: File or assembly name yi7sw1kj.dll, or one of its dependencies, was not found.
File name: "yi7sw1kj.dll"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyNa me assemblyRef, Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity)
at System.CodeDom.Compiler.CompilerResults.get_Compil edAssembly()
at System.CodeDom.Compiler.CompilerResults.get_Compil edAssembly()
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMap ping[] xmlMappings)
at System.Xml.Serialization.XmlSerializer.GenerateTem pAssembly(XmlTypeMapping xmlTypeMapping)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
at ACN_RFDWSI_TemplateInfo.ACN_RFDWSI_TemplateInfo.ge tViews(String def_id, String strReqInstance, String strReqContext) in c:\inetpub\wwwroot\acn_rfdwsi_templateinfo\acn_rfd wsi_templateinfo.asmx.cs:line 70
=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\DOCUME~1\SCHUSS~1\ASPNET\LOCALS~1\Temp\yi7sw1kj .dll
LOG: Appbase = file:///c:/inetpub/wwwroot/ACN_RFDWSI_TemplateInfo
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/DOCUME~1/SCHUSS~1/ASPNET/LOCALS~1/Temp/yi7sw1kj.dll.
What could be the reason for this problem?
Thanks a lot
Alex