Using a 32-bit DLL on a 64-bit system shows 0x8007000B Error

I need to use a third-party DLL in my application. The DLL is 32-bit, and the system I use is a 64-bit OS.

I imported a 32-bit DLL into the DotNet application (framework-4.5) as shown below

[DllImport("Sample.dll", EntryPoint = "Add", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] public static extern int Add(int iA, int iB); 

In IIS 7.5 - I installed "Enable 32-bit application" as "True."

And also tried to configure the compiler manager as - X86, x64 and any CPU.

But all attempts lead to the same error as

  An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) 

How to solve this problem......

+7
source share
3 answers

If you try to run 32-bit applications on IIS 7 (and / or a 64-bit operating system), you will get the same error. So, from IIS 7, right-click on the application pool and go to “advanced settings” and change “Enable 32-bit applications” to “TRUE”.

Restart your site and it should work.

+2
source

Select the Create in Configuration Manager check box for your executable file, for which processor it works, maybe you have some kind of CPU assembly. Restart Visual Studio so as not to complain that it could not debug the assembly.

Right-click the project and open "Properties-> Compile-> Advanced Compilation Settings-> Target CPU: it must correspond to the" Platform "that you are building. That is, if you are building" Any processor ", then" Target processor "should say “Any processor.” Go through all your platforms, make them active, and check this setting.

If you try to run 32-bit applications on IIS 7 (and / or a 64-bit operating system), you will get the same error. So, from IIS 7, right-click on the application pool and go to “advanced settings” and change “Enable 32-bit applications” to “TRUE”.

Restart your site and it should work.

0
source

I ran into this problem both when working with a 32-bit dll on a 64-bit machine, and when using the DllImport method, and forgot to install the appropriate redistributable library for what I called. I needed to install visual C ++, distributed sometimes when the called library had a dependency on it, and I also needed to install the distributed Intel Visual Fortran - when calling the Fortran function from the .NET library.

0
source

All Articles