STK 5 - Compiling on a 64-bit operating system

Brian DonahueBrian Donahue Posts: 6,590 New member
edited February 5, 2007 11:14AM in Knowledge Base
  • Date: 5 Feb 2007
  • Versions Affected: SQL Toolkit 5.x on x64 and Itanium computers
It is possible to compile a SQL Toolkit application on a 64-bit workstation with a 64-bit edition of Windows. Since the SQL Toolkit assemblies (RedGate.SQLCompare.Engine.dll, for instance) are 32-bit assemblies, the Visual Studio environment needs to be adjusted to compile your Toolkit project in 32-bit mode as well.

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:
System.BadImageFormatException: Licenses.licx is not a valid Win32 application
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.

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.
Sign In or Register to comment.