Tuesday, August 23, 2011

BadImageFormatException with ASP.NET and native dlls

There are times when you would like to use a native DLL with ASP.NET, and the ASP.NET compilation process fails with a BadImageFormatException because the compiler and the native DLL are different architectures (e.g. one is x86, and the other amd64) and the compiler will try to open all DLLs in the bin directory. Here is the web.config magic to avoid this issue. In this example, native.dll is the DLL I'd like the ASP.NET compiler to ignore.

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="false">
      <assemblies>
        <remove assembly="native"/>
      </assemblies>
    </compilation>
  </system.web>
</configuration>

1 comment:

  1. If you do not know where to download this dll file user32.dll then I advise you to visit this link http://fix4dll.com/user32_dll .

    ReplyDelete