0

I have a MVC 3 Web Site referencing a 32 bit DLL. The OS is Windows 2008 R2 x64. The website is in the ASP.NET 4 App Pool. I have turned on Enable32Bit but it doesn't work. I get a Bad Image Exception but can't find out to turn this level of logging on in IIS. I have setup up a page that outputs whether it's running 32bit or 64bit and when I turn on/off the Enable32Bit on the AppPool I get the correct output. The website is also in Full Trust.

I'm at a loss to try and and get it to work. I do know that it works on Win7 32bit.

Can you suggest some things to try?

UPDATE: I have just written a simple Windows Forms App with a button on it which calls my DLL. This was built with target of x86 and it worked fine so there is an issue with IIS or ASP.Net I think.

UPDATE 2: Does it matter if the ASP.Net Pipeline is Clasic or Integrated? I've tried both but same problem but thought it was worth asking

UPDATE 3: I found this question trying to do the same thing and he gave up which isnt too helpful!!

1
  • An application running as 64 bit can't load 32 bit DLLs. You have to make the application run in 32 bit mode from the start so it can load the DLL. Allowing 32 bit applications to run is not the same as making an application run as 32 bit when it would otherwise run as 64 bit.
    – Brian
    Jul 6, 2014 at 10:44

2 Answers 2

1

This is an old question, but you need to click on the application pool, then click Advanced Settings for the pool, and enable 32-bit applications. Without this, it'll always try to load 64-bit and you'll get that bad image error for 32 bit dlls.

1
  • this should be marked as the correct answer (old, but still good)
    – Leon
    Apr 27, 2015 at 12:39
0

If you get a Bad Image error, your 32 bit app is trying to load a 64-bit DLL. Does it name the DLL? (That seems too obvious not to mention it?)

So, you'll need to track down anywhere in the or section of that app that refers to a 64-bit DLL, and make sure you "shield" that line from 32 bit app pools by adding a preCondition="bitness64" to the line. (also check just in case).

The core .Net stuff (PageHandlerFactory/ASPNET ISAPI) is typically set up right in the first place, so focus on other modules/handlers.

Worst-case, try running Process Monitor while starting the app pool, identify the DLL from there, then work backwards to what's causing the problem.

Enjoy!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .