[英]Compile to x64 and received System.BadImageFormatException
I have a solution with a C# project of 'library' and a project 'JavaScript' after that compiled it generates a .winmd file being taken to another project. 我有一个解决方案,其中包含一个C#项目“ library”和一个项目“ JavaScript”,编译后生成一个.winmd文件,该文件将被带到另一个项目。 But this project is built on x86 and I need to compile for x64, to run the application in order x64 get the following error:
但是这个项目是基于x86构建的,我需要针对x64进行编译,才能运行应用程序,以便x64得到以下错误:
'WWAHost.exe' (Script): Loaded 'Script Code (MSAppHost/2.0)'.
Unhandled exception at line 25, column 13 in ms-appx://2c341884-5957-41b1-bb32-10e13dd434ba/js/default.js
0x8007000b - JavaScript runtime error: An attempt was made to load a program with an incorrect format.
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at System.Runtime.InteropServices.WindowsRuntime.ManagedActivationFactory.ActivateInstance()
WinRT information: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at System.Runtime.InteropServices.WindowsRuntime.ManagedActivationFactory.ActivateInstance()
The program '[5776] WWAHost.exe' has exited with code -1 (0xffffffff).
If I understand you correctly, the 'library' project is compiled specifically to x86, and you are consuming it from the javascript project which is targeting x64? 如果我理解正确,那么“库”项目是专门针对x86编译的,而您正在从以x64为目标的javascript项目中使用它?
If that is the case, you will not be able to make this work as the 64 bit process cannot load assemblies that are compiled for x86 explictily (you get the BadImageFormatException
mentioned). 如果真是这样,您将无法使此工作,因为64位进程无法显式加载针对x86编译的程序集(您会看到提到的
BadImageFormatException
)。
You options are to compiled the Javascript project in x86 mode, which will run on WoW, but I'm unsure how that relates to winmd files. 您可以选择以x86模式编译Javascript项目,该项目将在WoW上运行,但是我不确定这与winmd文件有什么关系。
Your best bet is if you have access to the 'library' project code, to compile it as 'Any CPU' so it can be used by processes running in any bitness. 最好的选择是,如果您可以访问“库”项目代码,则可以将其编译为“任何CPU”,以便供任意运行的进程使用。
After some time, I found the problem. 一段时间后,我发现了问题。 It is one of the dll's used possessed a method that had to be called problems, so it took was to identify .
它是使用过的dll之一,它具有一种必须称为问题的方法,因此需要进行识别。 But to replace the DLL , the problem was solved .
但是替换DLL后,问题解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.