2

I have a dll file. I used it in a Windows Form Application (C#) without problem.

Now I want to use in my ASP.NET website (C#), and I import it like my Windows Application like this:

[DllImport( "mydll.dll" )]
static extern int myfunc(int i);

But when I run my web site and use myfunc method it shows this error:

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

I don't know what's the problem.

Some more info:

It's 64-bit dll. I have an x64 cpu (Intel core i7). I don't have source code of dll. I have an IIS on my local computer and I'm testing on it.

1

1 Answer 1

1

You are probably running on x64 and your IIS is not setup to allow x86 assemblies.

Enable 32-bit DLLs in your Application Pool, as described here:

  1. Right click on your Application Pool
  2. Select Advanced Settings
  3. Change the value of "Enable 32-bit Applications" to true and click OK
Sign up to request clarification or add additional context in comments.

6 Comments

I did what you said, but it didn't solve the problem.
Give us some more information on your setup. Is it a 32-bit DLL? Do you have the DLL source code, can you recompile it to target x64? Is it happening locally or on server? Are you on x64? What version of IIS?
It's 64-bit dll. I have a x64 cpu (Intel core i7). I don't have the dll source. I have an IIS on my local computer and I'm testing on it.
Setup the environment as described on answer, try to restart iis with iisreset
There are any dependency on dll ? Check this stackoverflow.com/questions/2023766/… and this stackoverflow.com/questions/16896718/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.