Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

an attempt was made to load a program with an incorrect format exception going away with VS installation

I've designed a C# Windows appln which also calls internally some functions [imported from C++ DLL through DllImport()]

My C++ code is built as .DLL in Win32 platform whereas my C# is built as "Any CPU" platform.

When I run the .EXE (C#) in my test machine, I face an error as

an attempt was made to load a program with an incorrect format exception from hresult 0x8007000B

However, this error is not faced if I install VSS 2010 in my machine and then run the EXE.

1) Reason for this error? 2) why is the error not observed when VSS is installed?

I've used Win7 OS(64bit) to build the .EXE (C#) in AnyCPU platform which in turn depends on a DLL (C++ Dll imported in C# using DllImport) built in Win32

like image 209
stack_pointer is EXTINCT Avatar asked Sep 18 '12 18:09

stack_pointer is EXTINCT


1 Answers

This is almost always because you are calling 32bit code from 64bit dll/exe,etc or a 64bit dll from a 32bit dll. What happens if you build the c# for x86? It will still run on 64bit.

like image 113
Rob Allen Avatar answered Oct 10 '22 16:10

Rob Allen