woensdag 24 april 2013

.NET: Easy way to make ANY_CPU compiled DLL 32-bit

The default configuration in Microsoft .NET is compiling the DLL's as ANY_CPU. This means that in a 64-bit environment the code will look for 64-bit drivers and in a 32-bit environment for 32-bit drivers.

In a professional environment, you typically notice this when moving to Windows 2008 R2.  When you do not install 64-bit drivers, your software will not function anymore.

There is a solution, however: Use the Visual Studio tool CorFlags. The CorFlags Conversion tool allows you to configure the CorFlags section of the header of a portable executable image.

The following statement will set the DLL as 32-bit:
CorFlags.exe assembly.dll /32BIT+

Ofcourse, you can also recompile your software as X86, but in some cases which contain modifications in the build-scripts that may not be possible.

Notice that IIS 7.5 (Windows 2008 R2) does contain an advanced property in the Application Pool, which must be set to run 32-bit DLL's in IIS webapplications.

Geen opmerkingen:

Een reactie posten