The License Compiler (Lc.exe) throws an exception when a .NET Framework 2.0 application consumes licensed components on a computer that is running a 64-bit operating system (913961)



The information in this article applies to:

  • Microsoft .NET Framework 2.0
  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio 2005 Express Edition

SYMPTOMS

Consider the following scenario. You build a Microsoft .NET Framework 2.0-based application in Microsoft Visual Studio 2005. The application consumes licensed components on a computer that is running a 64-bit operating system. However, you compiled the application for a 32-bit operating system. In this scenario, the License Compiler (Lc.exe) throws an exception that is similar to the following:
Exception occurred creating type 'LicensedComponent.UserControl1, LicensedComponent, Version=1.0.1.100, Culture=neutral, PublicKeyToken=null' System.ComponentModel.LicenseException: A valid license cannot be granted for the type LicensedComponent.UserControl1. Contact the manufacturer of the component for more information. C:\Documents and Settings\Administrator\Desktop\LC\LCIssue\64BitIssue\Properties\licenses.licx 1 64BitIssue

CAUSE

This problem occurs because Lc.exe always runs as a 64-bit application on a computer that is running a 64-bit operating system. However, Lc.exe does not support 32-bit applications that are running on 64-bit operating systems. Lc.exe only supports 32-bit applications that are running on 32-bit operating systems.

RESOLUTION

To resolve this problem, run the Ldr64.exe command from the pre-build event in your application. When you do this, you can force all code to run as a 32-bit application. To do this, follow these steps:
  1. In Solution Explorer, right-click your project, and then click Properties.
  2. Click Build Events, and then add the following command to the Pre-built event command line box:
    Ldr64.exe setWow
  3. Add the following command to the Post-build events command line box:
    Ldr64 set64

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

For more information about Lc.exe, visit the following Microsoft Developer Network Web site:

Modification Type:MajorLast Reviewed:2/25/2006
Keywords:kbProgramming kberrmsg kbtshoot kbprb KB913961 kbAudDeveloper kbAudITPRO