INFO: Workaround for a license compiler exception when targeting x64 in .NET framework 2.0, 3.0, or 3.5


Special Note

.NET Frameworks 2.0 and 3.0 are no longer supported on supported OSes  - .NET Framework 3.5 is soon to reach end of support from Microsoft. All users still on these older frameworks are strongly encouraged to move to tareting .NET Framework 4.5.2 or higher (up to 4.8 - Moving to .NET 6 has mutlple breaking changes and requires special attention, but moving an app that targets 2.0, 3.0 or 3.5 is mostly a case of just changing the build target, and switching to our 4.5.2 dlls  - note .NET 4.0, 4.5 and 4.5.1 have ended support so 4.5.2 is the lowest supported .NET Framework from DotImage for our newer releases.

Workaround

We have found that there is a bug in Visual Studio when it comes to building a 64-bit application on a 64-bit system. Visual Studio will use the 32-bit version of license compiler (LC.exe) when the build configuration is set to x64.

Please note, this article refers to Visual Studio 2008/2010 and .NET framework 2.0, 3.0, and 3.5 ... for correct information regarding x64and .NET framework 4.0 and up, please refer to INFO: Workaround for a license compiler exception when targeting x64 in .NET framework 4.0 and up

To workaround this issue you will need to modify your application project file in a text editor. Add the highlighted line shown below to all of your 64-bit build configurations:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols> <OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<LCToolPath>C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\bin\x64</LCToolPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<LCToolPath>C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\bin\x64</LCToolPath>
</PropertyGroup>

This will tell Visual Studio where to get the license compiler during a build.

For more information, please see:

INFO: Bitness Roundup Whitepaper: x86, x64, AnyCPU

Original Article:
Q10288 - INFO: Workaround for a license compiler exception when targeting x64 in .NET framework 2.0, 3.0, or 3.5