我在使用 Spoon Studio 和 .Net 4.0 打包的虚拟化应用程序中遇到以下异常
Exception='System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\temp\Serialization\mf3je3jx.dll' or one of its dependencies. The system cannot find the file specified.
File name: 'file:///C:\temp\Serialization\mf3je3jx.dll'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
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.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
在我们使用 .Net 3.5 之前,它工作正常,但在迁移到 .Net 4.0 包后,我们开始看到这个错误。
我知道解决这个问题的一种方法是预先生成 XmlSerializers,但在我们的例子中,我们有多个加载项也需要重建,我们希望避免这样做。
我的问题是为什么会发生这种情况?为什么运行时无法在运行时生成序列化程序?我可以看到在临时目录中生成了 .cs 和 .out 文件(dll 也会暂时生成并立即删除)。
如果我在没有虚拟化的情况下运行我的应用程序,它可以正常工作并且能够构建和加载内存中序列化程序。在这两种情况下,运行应用程序的用户都是相同的。
欢迎提出任何建议。
It's a separate problem but I'm unable to debug this within VS or windbg (I get clr version mismatch error b/w VS and Application)
reason being: installing VS12/.Net 4.5 on the machine upgrades the CLR version number to 4.0.30319.17929 whereas application uses 4.0.30319.1. and VS doesn't allow me to attach to this application
最佳答案
我们已找到问题。
Spoon Studio 为 .Net 4.0 使用的默认 .Net 图像中没有所有必需的程序集。
这是 Spoon Studio 中的错误。我通过从 SpoonStudio 团队获取新的自定义图像来实现它。
关于c# - 使用 Spoon Studio .Net 4.0 构建的应用程序中带有 XmlSerializers 的 FileNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14241169/