0

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. 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:

'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).
Delimitry
  • 2,987
  • 4
  • 30
  • 39

2 Answers2

0

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?

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).

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.

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.

Steve Danner
  • 21,818
  • 7
  • 41
  • 51
  • So I tried to create a new project and copy the classes and .dll files that are referenced in the solution. I'm trying to compile the project to 'Any CPU' option, but I'm getting the same exception. –  Jun 26 '15 at 17:59
  • Are there some native dlls being loaded? I see now the error is coming from interop services? – Steve Danner Jun 27 '15 at 13:44
  • Yes, there are some dlls, (I have them both x64 and for x32) when they are loaded I use the dll their compilation architecture. –  Jun 29 '15 at 12:12
0

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 . But to replace the DLL , the problem was solved .