C# XML反序列化成类时(XmlSerializer)报 System.IO.FileNotFoundException: 未能找到文件的问题

在服务器有一个Remoting程序,通过WebService 向Remoting传送序列化的类的Xml字符串,由Remoting反序列化,在本机调试时没有问题,但放在Remoting上则会报反序列化失败,

System.IO.FileNotFoundException: 未能找到文件“C:\Users\Administrator\AppData\Local\Temp\hnlcjqq_.dll”。
文件名:“C:\Users\Administrator\AppData\Local\Temp\hnlcjqq_.dll”
   在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   在 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)
   在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   在 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)


微软的解释是反序列化时,需要编译这些文件,当 XmlSerializer 试图加载由调用 System.Reflection.Assembly.Load 方法的 CodeDOM 生成的程序集。

见:http://msdn.microsoft.com/zh-cn/library/aa302290.aspx

结果将Remoting的兼容性改为以管理员身份运行此程序就正常。


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值