BUG: You may receive the "COM interop registration failed" error message when you try to rebuild the Visual C# Library application (821313)



The information in this article applies to:

  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)

SYMPTOMS

When you try to rebuild a Visual C# Library application with the Register for COM Interop build property set to true in Visual Studio .NET, you may receive the following error message:
COM Interop registration failed. Access is denied.

CAUSE

This problem may be caused by one of the following:
  • File Lock - Another instance of Visual Studio .NET holds a file lock to the type library (.tlb) that was generated during the Visual C# Library application build.
  • Registry Permissions - A problem with permissions in the registry prevents the generated type library from being registered or prevents the classes in the assembly from being registered.

WORKAROUND

To work around this problem, use one of the following methods:
  • Workaround for File Lock
    1. Close the instance of Visual Studio .NET that currently holds the reference to the control.
    2. Close the instance of Visual Studio .NET.
    3. Rebuild the Visual C# Library application.
  • Workaround for Registry Permissions - Modify the permissions with the help of Resource Kit tools (for example, Regini.exe).
For additional information about how to use Regini.exe to set permissions on registry keys, click the following article number to view the article in the Microsoft Knowledge Base:

237607 How to Use Regini.exe to Set Permissions on Registry Keys

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a Visual C# Windows Control Library project in Visual Studio .NET.
  2. In Solution Explorer, right-click Project, and then click Properties.
  3. In the left pane of the Property Pages dialog box, click Build under Configuration Properties.
  4. In the right pane, set the Register for COM Interop property to True.
  5. Build the application.
  6. Start a second instance of Visual Studio .NET and create a Visual C# Windows Application.
  7. Right-click Windows Forms Toolbox, and then click Add/Remove Items.
  8. In the Customize Toolbox dialog box, click .NET Framework Components, and then click Browse.
  9. In the Open dialog box, locate the path for Windows Control Library (that you created in step 1), and then click Open.
  10. Click OK to close the Customize Toolbox dialog box.
  11. Drag the windows control from Windows Forms Toolbox (that was added earlier in these steps) onto the form.
  12. Build the application.
  13. Rebuild the Windows Control Library project in the first instance of Visual Studio .NET.

    You may notice the error that is mentioned in the "Symptoms" section.

Modification Type:MinorLast Reviewed:1/19/2006
Keywords:kbide kbControl kbbug KB821313 kbAudDeveloper