开发者

32bit dll not loading with Enable32Mode on IIS 7.5

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开发者_如何学C 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.


Better you should build the unmanaged dll either in 64 bit mode or Any CPU mode.Sometimes it will load the 32 bit assembly while we enable 32 bit application in Application Pool where the application is hosted. If it is not working with this option it should be replaced with 64 bit library. Also recycle the application pool and restart the iis. Hope it will work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜