c# - Intermittent errors while de-serializing object from XML -


i have program takes objects stored xml in database (basicly message queue) , de-serializes them. intermittently, 1 of following errors:

system.runtime.interopservices.externalexception: cannot execute program. command being executed "c:\windows\microsoft.net\framework\v2.0.50727\csc.exe" /noconfig /fullpaths @"c:\documents , settings\useraccount\local settings\temp\lh21vp3m.cmdline".    @ system.codedom.compiler.executor.execwaitwithcaptureunimpersonated(safeusertokenhandle usertoken, string cmd, string currentdir, tempfilecollection tempfiles, string& outputname, string& errorname, string truecmdline)    @ system.codedom.compiler.executor.execwaitwithcapture(safeusertokenhandle usertoken, string cmd, string currentdir, tempfilecollection tempfiles, string& outputname, string& errorname, string truecmdline)    @ microsoft.csharp.csharpcodegenerator.compile(compilerparameters options, string compilerdirectory, string compilerexe, string arguments, string& outputfile, int32& nativereturnvalue, string trueargs)    @ microsoft.csharp.csharpcodegenerator.fromfilebatch(compilerparameters options, string[] filenames)    @ microsoft.csharp.csharpcodegenerator.fromsourcebatch(compilerparameters options, string[] sources)    @ microsoft.csharp.csharpcodegenerator.system.codedom.compiler.icodecompiler.compileassemblyfromsourcebatch(compilerparameters options, string[] sources)    @ system.codedom.compiler.codedomprovider.compileassemblyfromsource(compilerparameters options, string[] sources)    @ system.xml.serialization.compiler.compile(assembly parent, string ns, xmlserializercompilerparameters xmlparameters, evidence evidence)    @ system.xml.serialization.tempassembly.generateassembly(xmlmapping[] xmlmappings, type[] types, string defaultnamespace, evidence evidence, xmlserializercompilerparameters parameters, assembly assembly, hashtable assemblies)    @ system.xml.serialization.tempassembly..ctor(xmlmapping[] xmlmappings, type[] types, string defaultnamespace, string location, evidence evidence)    @ system.xml.serialization.xmlserializer.generatetempassembly(xmlmapping xmlmapping, type type, string defaultnamespace)    @ system.xml.serialization.xmlserializer..ctor(type type, string defaultnamespace)    @ system.xml.serialization.xmlserializer..ctor(type type)    ..... 

or i'll one:

system.invalidoperationexception: unable generate temporary class (result=1). error cs0016: not write output file 'c:\documents , settings\useraccount\local settings\temp\nciktsd7.dll' -- 'could not execute cvtres.exe.'     @ system.xml.serialization.compiler.compile(assembly parent, string ns, xmlserializercompilerparameters xmlparameters, evidence evidence)    @ system.xml.serialization.tempassembly.generateassembly(xmlmapping[] xmlmappings, type[] types, string defaultnamespace, evidence evidence, xmlserializercompilerparameters parameters, assembly assembly, hashtable assemblies)    @ system.xml.serialization.tempassembly..ctor(xmlmapping[] xmlmappings, type[] types, string defaultnamespace, string location, evidence evidence)    @ system.xml.serialization.xmlserializer.generatetempassembly(xmlmapping xmlmapping, type type, string defaultnamespace)    @ system.xml.serialization.xmlserializer..ctor(type type, string defaultnamespace)    @ system.xml.serialization.xmlserializer..ctor(type type)    .... 

the program process thousands of messages day successfully, these errors maybe 2 or 3 times day. don't appear correlated specific kind of message, random.

any idea causes errors , how fix it?

eta - here's code causing errors, in case helps:

public class messagecontextbuilder<t> t : messagecontextbase  {     private static idictionary<string, xmlserializer> serializercache { get; set; }     public ilog logger { get; set; }       public messagecontextbuilder() {         if (serializercache == null) serializercache = new dictionary<string, xmlserializer>();         logger = logcontextmanager.context.getlogger<messagecontextbuilder<t>>();     }      public t buildcontextfrommessage(iemailqueuemessage msg) {         xmlserializer serializer = getserializer(typeof(t));         xmlreader r = xmlreader.create(new stringreader(msg.messagedetails));         if (serializer.candeserialize(r)) {             t rval = (t)serializer.deserialize(r);             rval.emailaddress = msg.emailaddress;             rval.localeid = msg.localeid;             rval.storeid = msg.storeid;             rval.messageid = msg.uniquekey;             return rval;         } else {             throw new argumentexception("cannot deserialize xml in message details message #" + msg.uniquekey);         }     }      public xmlserializer getserializer(type t) {         if (!serializercache.containskey(t.fullname)) {             serializercache.add(t.fullname, new xmlserializer(t)); // error occurs here, in xmlserializer constructor, intermittently         }         return serializercache[t.fullname];     } } 

you can pre-create serializers: http://msdn.microsoft.com/en-us/library/bk3w6240%28v=vs.100%29.aspx give try. next canonical candidate such problems virus scanner. tool writing disc while creating serializers. have seen virus scanner producing kind of strange errors in such situations.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -