Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
581 views
in Technique[技术] by (71.8m points)

admin - 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:SitesWebsiteMyPortal.Website.ControllersinDebugMyPortal.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:SitesWebsiteMyPortal.Website.ControllersinDebugMyPortal.Website.Controllers.dll
c:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.Common.targets(3341,9): warning MSB3214: "D:SitesWebsiteMyPortal.Website.ControllersinDebugMyPortal.Website.Controllers.dll" does not contain any types that can be registered for COM Interop.
c:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.Common.targets(3341,9): error MSB3213: Cannot register type library "D:SitesWebsiteMyPortal.Website.ControllersinDebugMyPortal.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:TFSProjectSrcProjectAddininDebug ProjectAddin.dll" - access denied. Please make sure you're running the application as administrator. Access to the registry key 'HKEY_CLASSES_ROOTCLSID{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:TFSProjectSrcProjectAddininDebug 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...