I'm building my VS2010 solution and in output window there is 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?
I found out someone changed a property in the csproj.
To solve the error:
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:
The above registry key didn't exist so I created it, then trying to compile I got:
Solution
Turn off Register for COM interop and the error goes away.
Shift + Right click Visual Studio and open as Administrator, open the project. Tick Register for Com interop and it compiles successfully.
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:
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