Microsoft KB Archive/821313

= BUG: You may receive the &quot;COM interop registration failed&quot; error message when you try to rebuild the Visual C# Library application =

Article ID: 821313

Article Last Modified on 1/19/2006

-

APPLIES TO


 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition

-





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
 * Close the instance of Visual Studio .NET that currently holds the reference to the control.
 * Close the instance of Visual Studio .NET.
 * 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.



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 &quot;Symptoms&quot; section.

Keywords: kbbug kbide kbcontrol KB821313

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.