简体   繁体   English

编译为x64并收到System.BadImageFormatException

[英]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.

相关问题 无法在Windows 10 x64上安装hiredis@0.5.0 - Unable to Installing hiredis@0.5.0 on Windows 10 x64 在Windows 7 x64下构建上下文(对于NodeJS jQuery) - Building contextify under Windows 7 x64 (for NodeJS jQuery) 如何在x64 MacOS X 10.7上检查`node --prof`的结果? - How to inspect result of `node --prof` on x64 MacOS X 10.7? 为 Win32 x64 编译后,Electron 应用程序无法打开 - Electron app won't open after compiling for Win32 x64 Javascript window.open在Win7 x64上的32位IE8中返回null - Javascript window.open returns null in 32-bit IE8 on Win7 x64 为什么 getStaticProps 给出“无法为 win32/x64 加载 SWC 二进制文件”的错误? - Why getStaticProps giving error of "Failed to load SWC binary for win32/x64"? 通过在Windows XP x64上使用JScript执行.hta文件,“访问被拒绝” - “Access is denied” by executing .hta file with JScript on Windows XP x64 Vista x64,小工具开发,OLEDB错误:“找不到提供程序” - Vista x64, gadget development, OLEDB Error: “provider cannot be found” window.open(“ \\\\\\\\ localhost \\\\”); 不适用于win7(x64)ie8 - window.open(“\\\\localhost\\”); not working on win7(x64) ie8 Javascript Intellisense无法在Visual Studio 2010 Ultimate(Windows 7 x64)上运行 - Javascript Intellisense not working on Visual Studio 2010 Ultimate (Windows 7 x64)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM