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"?>
    <compilation debug="false">
        <remove assembly="native"/>

No comments:

Post a Comment