XmlSerializer Constructor File Not Found Exception in production
Why am I getting file not found exceptions with the XmlSerializer constructor in a production environment?

The following is being executed on a shared server using ASP.NET.  Compiling in debug mode is off in  web.config.

    void SerializeSomething(Type type)
    {
        XmlSerializer xs = new XmlSerializer(type);
        ...
    }

This doesn't occur consistently, but it occurs quite often.  It seemed to stop occurring when I set my assembly's "Generate serialization assembly" to "On".  When I uploaded the newly compiled assemblies, I received compiler errors in ASP.NET.  Having the host reset IIS fixed that.

A few days later, the file not found errors reappeared in great number.  Some answers on this site have said to turn off this exception in Visual Studio, but that does me no good as it's occurring in my production environment.

Could this somehow be a symptom of the problems with a shared hosting environment?  Will upgrading to ASP.NET 4.0 fix this?

Could not load file or assembly 'C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files\\mysite\\4e8c0622\\86b4dcf0\0eibiezu.dll' or one of its dependencies. The system cannot find the file specified.
  at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
  at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
  at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
  at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity)
  at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
  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)
  at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
  at System.Xml.Serialization.XmlSerializer..ctor(Type type)
XmlSerializer Constructor File Not Found Exception in production
===

Why am I getting file not found exceptions with the XmlSerializer constructor in a production environment?

The following is being executed on a shared server using ASP.NET.  Compiling in debug mode is off in  web.config.

    void SerializeSomething(Type type)
    {
        XmlSerializer xs = new XmlSerializer(type);
        ...
    }

This doesn't occur consistently, but it occurs quite often.  It seemed to stop occurring when I set my assembly's "Generate serialization assembly" to "On".  When I uploaded the newly compiled assemblies, I received compiler errors in ASP.NET.  Having the host reset IIS fixed that.

A few days later, the file not found errors reappeared in great number.  Some answers on this site have said to turn off this exception in Visual Studio, but that does me no good as it's occurring in my production environment.

Could this somehow be a symptom of the problems with a shared hosting environment?  Will upgrading to ASP.NET 4.0 fix this?

Could not load file or assembly 'C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files\\mysite\\4e8c0622\\86b4dcf0\0eibiezu.dll' or one of its dependencies. The system cannot find the file specified.
  at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
  at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
  at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
  at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity)
  at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
  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)
  at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
  at System.Xml.Serialization.XmlSerializer..ctor(Type type)