STK 5 - Compiling on a 64-bit operating system
Brian Donahue
Posts: 6,590 Bronze 1
- Date: 5 Feb 2007
- Versions Affected: SQL Toolkit 5.x on x64 and Itanium computers
The first step is to make sure your compiler is producing 32-bit code. In Visual Studio .NET 2005, this means entering the project properties, selecting the Build category and setting the Platform Target to x86.
If you have purchased a licence for SQL Toolkit, another issue will surface, namely that Visual Studio needs to know to call the 32-bit version of lc.exe, which is Microsoft's licence compiler that ships with Visual Studio that is leveraged to compile the SQL Toolkit licence into your assembly. By default, Visual Studio loads the 64-bit version of lc.exe, causing an error message upon compilation similar to the following:
In order to prevent this, further project settings need to be changed in Visual Studio 2005, namely to add a pre-and-post-build event to change the compilation environment.System.BadImageFormatException: Licenses.licx is not a valid Win32 application
Right-click the project and select properties. Next, click Build Events.
Set a new pre-build event:
c:/WINDOWS/Microsoft.NET/Framework64/v2.0.50727/Ldr64.exe setwow
Set a new post-build event:
c:/WINDOWS/Microsoft.NET/Framework64/v2.0.50727/Ldr64 set64
Note that the paths may differ based on the installation folder of your .NET Framework.