Visual Studio - TYPE_E_REGISTRYACCESS
Asked Answered
H

4

20

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?

Handset answered 24/2, 2011 at 16:56 Comment(4)
do you run Vs2010 as administrator?Creamer
no it is not needed to run it as administratorHandset
And if you need to register the compiled assembly for COM Interop do you then need to run as admin?Inclinometer
@JuniorMayhé your answer isn't a solution when you need say an Excel Add-In to Register for COM interop. Unfortunately Rory's didn't work for me either.Puma
H
26

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
Handset answered 25/2, 2011 at 8:42 Comment(4)
That solution may break the build, as it will stop COM interop registrationDozen
I have unchecked "Register for COM interop" and the error persists.. I'm using Team Build 2010... any ideas?Skindive
@Skindive run VS as administarotFirstrate
Register for COM interop is checked intentionally to register COM interop.Hokanson
P
40

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.

Puma answered 4/6, 2012 at 23:2 Comment(3)
Hi all, this the way I found out, please understand this is a different kettle of fish: #10875778Puma
For me, running Visual Studio in administrator mode solved this issue. I no longer get the errors. Thanks, @Jeremy!Catinacation
Glad it helped @Daniel, it's cool to upvote answers that helpPuma
H
26

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
Handset answered 25/2, 2011 at 8:42 Comment(4)
That solution may break the build, as it will stop COM interop registrationDozen
I have unchecked "Register for COM interop" and the error persists.. I'm using Team Build 2010... any ideas?Skindive
@Skindive run VS as administarotFirstrate
Register for COM interop is checked intentionally to register COM interop.Hokanson
O
11

For me this problem started when I moved to a Win7 x64 machine. I have other team members without x64 so I assume this is the problem. I need COM interop so can't just turn it off. I was able to solve the problem by un-checking Register for COM interop (in project properties > Build page), and then adding a post-build event to do the COM registration:

"%Windir%\Microsoft.NET\Framework\v2.0.50727\regasm" /codebase "$(TargetPath)"
Ozone answered 21/7, 2011 at 15:0 Comment(2)
this worked for me. As I also needed the com and I was building on X64 machine.Arbela
+1 this was a good idea but didn't work for me, I'll post my solution.Puma
P
3

Since, in your project you have enabled Register for COM interop setting, the same is being executed at the build time. This setting needs admin privileges which are not available under Visual Studio unless you launch Visual Studio as administrator, explicitly.

You can follow the steps available at the following link to launch Visual Studio as administrator and then try building your project again -

How to Run Visual Studio as Administrator by default

Puglia answered 3/11, 2016 at 9:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.