IIS7 App Pool can't load library with Fixed Ba

2019-07-04 21:46发布

问题:

My .NET 4.0 Web services are using libeay32.dll, which is compiled in VS2010 with the /FIXED option in order to be FIPS compliant. This means that libeay32.dll fails to load unless it gets to live in a certain address (0xfb00000). The exception thrown is:

System.DllNotFoundException: Unable to load DLL 'some_dependent_library.dll': Attempt to access invalid address.

The only way I know to help guarantee that libeay32.dll gets the right address is to load it in a Main() method before any other DLLs are loaded (using LoadLibrary() from kernel32.dll). This is an approach that I've used with success in my Windows Services and unit tests. However, in my Web Services, I've put the LoadLibrary in Application_Start() of my Global.asax.cs, but it is still sporadically failing. (I've looked in procmon - lots of other DLLs are loaded first)

Is there any other way that I can ensure that libeay32.dll gets the required address? Is there code I can run when my App Pool starts up, but before Application_Start()?