Using 32-bit dll on 64-bit system shows 0x8007000B Error
Asked Answered
M

3

7

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

I have Imported the 32-bit DLL in my DotNet application (framework-4.5) as 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 have set "Enable 32-bit Application" as "True".

And also tried setting the Compiler Manager as - X86, x64 and Any CPU.

But all the attempt results in same Error as

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

How to resolve this Issue......

Magnification answered 14/5, 2013 at 9:21 Comment(3)
May be you can find your answer here <#3440345>Hendrik
possible duplicate of How to run VS 2010 Local IIS in 32 bit modeDysphonia
see this post about the 0x8007000B Error #18008467Yardarm
F
2

If you try to run 32-bit applications on IIS 7 (and/or 64-bit OS machine), you will get the same error. So, from the IIS 7, right click on the applications' application pool and go to "advanced settings" and change "Enable 32-Bit Applications" to "TRUE".

Restart your website and it should work.

Farant answered 14/5, 2013 at 13:1 Comment(0)
C
0

Check the Build checkbox in the Configuration Manager for your executable, what CPU it is running for, probably you have Any CPU build there. Restart Visual Studio then to not complain that it couldn't debug the assembly.

Right-click on the project and open Properties->Compile->Advanced Compile Options->Target CPU: it should match the "Platform" you are building. That is, if you are building "Any CPU" then "Target CPU" should say "Any CPU". Go through all of your Platforms by making them active and check this setting.

If you try to run 32-bit applications on IIS 7 (and/or 64-bit OS machine), you will get the same error. So, from the IIS 7, right click on the applications' application pool and go to "advanced settings" and change "Enable 32-Bit Applications" to "TRUE".

Restart your website and it should work.

Conover answered 14/5, 2013 at 9:32 Comment(2)
Hi. I have done all the things u mentioned in 1st para and also in 3rd para. But it result in same error... When tried to see the Compiler Option, the Properties has no option like "Compile->Advanced Compiler Options"Magnification
it depends on particular project, what your application is exactly?Conover
K
0

I have experienced this problem both when I was running a 32-bit dll on a 64-bit machine and when using the DllImport method and forgetting to install the appropriate redistributable library for what I was calling. I've needed to install the visual c++ redistributable on occasion when a called library had a dependency on that and I've also needed to install the Intel Visual Fortran redistributable - when calling a Fortran function from a .NET library.

Karyolymph answered 22/9, 2016 at 15:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.