Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio - TYPE_E_REGISTRYACCESS

I'm building my Visual Studio solution and in the output window there's an error just for one project.

In error tab:

Error   161 Cannot register type library "D:\Sites\Website\MyPortal.Website.Controllers\bin\Debug\MyPortal.Website.Controllers.tlb". Error accessing the OLE registry. (Exception from HRESULT: 0x8002801C (TYPE_E_REGISTRYACCESS)) MyPortal.Website.Controllers

In output tab:

Compile complete -- 0 errors, 153 warnings
  MyPortal.Website.Controllers -> D:\Sites\Website\MyPortal.Website.Controllers\bin\Debug\MyPortal.Website.Controllers.dll
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3341,9): warning MSB3214: "D:\Sites\Website\MyPortal.Website.Controllers\bin\Debug\MyPortal.Website.Controllers.dll" does not contain any types that can be registered for COM Interop.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3341,9): error MSB3213: Cannot register type library "D:\Sites\Website\MyPortal.Website.Controllers\bin\Debug\MyPortal.Website.Controllers.tlb". Error accessing the OLE registry. (Exception from HRESULT: 0x8002801C (TYPE_E_REGISTRYACCESS))
========== Rebuild All: 8 succeeded, 1 failed, 0 skipped ==========

Any ideas?

like image 645
Junior Mayhé Avatar asked Feb 24 '11 16:02

Junior Mayhé


People also ask

How do I run Visual Studio in elevated mode?

Run Visual Studio as an administratorOpen the Start menu, and scroll to Visual Studio. From the right-click or context menu of Visual Studio 2019 or Visual Studio 2022, select More > Run as administrator.

Why do I need Visual Studio as administrator?

Without Administrative permissions Visual Studio is not able to write to the hard drive outside of your specific user account privileges. This severely limits what can be done to build custom ArcGIS based applications.

What is register for COM interop?

Allows your managed .NET assembly to be accessible from an unmanaged COM library. This option will cause Visual Studio to automatically register your assembly as a COM component in the windows registry when the project is compiled. Registering for COM Interop requires administrator permissions.


2 Answers

When setting Register For Com interop I've found that you do need to run as Administrator.

Without Administrator trying to compile I got errors like:

Cannot register assembly "C:\TFS\Project\Src\ProjectAddin\bin\Debug \ProjectAddin.dll" - access denied. Please make sure you're running the application as administrator. Access to the registry key 'HKEY_CLASSES_ROOT\CLSID{3A6192EA-3C9C-39EB-99A3-3DBFF8CA118F}' is denied.

The above registry key didn't exist so I created it, then trying to compile I got:

Cannot register type library "C:\TFS\Project\Src\ProjectAddin\bin\Debug \ProjectAddin.tlb". Error accessing the OLE registry. (Exception from HRESULT: 0x8002801C (TYPE_E_REGISTRYACCESS))

Solution

Turn off Register for COM interop and the error goes away, or the better solution:

Shift + Right click Visual Studio and open as Administrator, open the project. Tick Register for Com interop and it compiles successfully.

like image 108
Jeremy Thompson Avatar answered Oct 20 '22 09:10

Jeremy Thompson


I found out someone changed a property in the csproj.

To solve the error:

  • You just have to right click the project,
  • choose Build tab
  • go to Output section
  • uncheck Register for COM interop
like image 34
Junior Mayhé Avatar answered Oct 20 '22 09:10

Junior Mayhé