XML Serialization issue

C

compurhythms

I have a .NET Windows Service that needs to run without interruption
for long periods of time (weeks or months). Everything works great
except that every once in a great while I get the following type of
exception when reading data from a file via XML Serialization:

System.IO.FileNotFoundException: Could not find file 'C:\WINDOWS\TEMP
\muodpwwm.dll'. (see rest of call stack below).

The problem is that the serialization works for hours, but once I get
this error it fails on every subsequent attempt. The standard answer
I've found is to give my service account read/write on Windows\TEMP.
But it already has that so something else is causing this. Also, I'm
serializing the same type every time, so it is not an issue of the
type having inherent serialization issues.

here's the kicker, I've tried to precompile a serialization assembly
using SGEN.exe, which will create a compield assembly used to
serialize your types instead of compiling one on the fly. But the
runtime does not seem to be using it. For example, if the assembly
that has my types is Foo.Bar.dll then I've generated
Foo.Bar.XmlSerializers.dll and placed it in the same directory.

But my app still seems to be compiling the serialization DLLs on the
fly. The docs for this are really thin. Is there something else I
needto be doing to make sure the my precompiled serialization assembly
is used?


---
File name: 'C:\WINDOWS\TEMP\muodpwwm.dll'
at System.IO.__Error.WinIOError(Int32 errorCode, String
maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share)
at
Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters
options, String[] fileNames)
at
Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters
options, String[] sources)
at
Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters
options, String[] sources)
at
System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters
options, String[] sources)
at System.Xml.Serialization.Compiler.Compile(Assembly parent,
String ns, XmlSerializerCompilerParameters xmlParameters, Evidence
evidence)
at
System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
XmlSerializerCompilerParameters parameters, Assembly assembly,
Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, String location,
Evidence evidence)
at
System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping
xmlMapping, Type type, String defaultNamespace)
....
// etc
---
 
C

compurhythms

I have a .NET Windows Service that needs to run without interruption
for long periods of time (weeks or months). Everything works great
except that every once in a great while I get the following type of
exception when reading data from a file via XML Serialization:

System.IO.FileNotFoundException: Could not find file 'C:\WINDOWS\TEMP
\muodpwwm.dll'. (see rest of call stack below).

The problem is that the serialization works for hours, but once I get
this error it fails on every subsequent attempt. The standard answer
I've found is to give my service account read/write on Windows\TEMP.
But it already has that so something else is causing this. Also, I'm
serializing the same type every time, so it is not an issue of the
type having inherent serialization issues.

here's the kicker, I've tried to precompile a serialization assembly
using SGEN.exe, which will create a compield assembly used to
serialize your types instead of compiling one on the fly. But the
runtime does not seem to be using it. For example, if the assembly
that has my types is Foo.Bar.dll then I've generated
Foo.Bar.XmlSerializers.dll and placed it in the same directory.

But my app still seems to be compiling the serialization DLLs on the
fly. The docs for this are really thin. Is there something else I
needto be doing to make sure the my precompiled serialization assembly
is used?

---
File name: 'C:\WINDOWS\TEMP\muodpwwm.dll'
at System.IO.__Error.WinIOError(Int32 errorCode, String
maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share)
at
Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters
options, String[] fileNames)
at
Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters
options, String[] sources)
at
Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.-CompileAssemblyFromSourceBatch(CompilerParameters
options, String[] sources)
at
System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerP-arameters
options, String[] sources)
at System.Xml.Serialization.Compiler.Compile(Assembly parent,
String ns, XmlSerializerCompilerParameters xmlParameters, Evidence
evidence)
at
System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
XmlSerializerCompilerParameters parameters, Assembly assembly,
Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, String location,
Evidence evidence)
at
System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping
xmlMapping, Type type, String defaultNamespace)
...
// etc
---

I believe that I have solved it. The XMLSerializers DLL seems to need
to be the same version as the source DLL. Once I sync'd the versions
my tests have run continuously for 2 days (and counting).

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top