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. Here is the code that is being used to reference the DLL:
[DllImport("CDCrypt.dll")]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern String Encrypt([MarshalAs(UnmanagedType.LPStr)] String aName);
[DllImport("CDCrypt.dll")]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern String Decrypt([MarshalAs(UnmanagedType.LPStr)] String aName);
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!!
Make sure that all the managed assemblies are targeting x86 instead of Any CPU or x64 in the properties of the project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With