IIS7 An attempt was made to load a program with an incorrect format P/invoke

Posted: 2012-01-18 in .Net, Code and Computers

If your website returns IIS7 or IIS 7.5

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

Its usually a result from code attempting to execute a dll using p Invoke and the dll being 32bit while running on a 64 bit machine.

For applications you should be fine to right click – properties – compatabilty and change the compatability mode.

For IIS 7 and 7.5 you need to set the application pool of the website throwing this error to enable 32 bit applications.

This can be done by:

Open Server Manager
Expand Roles
Expand Web Server (IIS)
Click on Internet Information Server

Expand the server (usually the one your on) in question
Click on Application Pools

Highlight the application pool that your web site is using (usaully has the same name if not the information can be found in the basic settings of the web site)
On the far right click on advanced settings

In the window select
Enable 32-Bit Applications and set to true

Restart the application pool

Test and try again.

The best solution though is to simply upgrade the dll 🙂

Hope this helps,
Choco

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s