简体   繁体   English

如何取消注册/删除在注册表中创建的所有COM条目

[英]How do I unregister/remove all COM entries created in registry

How do I remove all COM entries registered in the registry for a ProgID("Log.Main"). 如何删除注册表中为ProgID(“Log.Main”)注册的所有COM条目。

I have a COM component which is registered using regasm and now I could see a multiple class Ids for this COM Component(using oleview.exe) under CLSIDs in registry("Log.Main"). 我有一个使用regasm注册的COM组件,现在我可以在注册表(“Log.Main”)中的CLSID下看到这个COM组件(使用oleview.exe)的多个类ID。

I want remove all entries related to this COM component with ProgID 'Log.Main' from registry using C# or is there any tools available other that registry cleaners. 我想使用C#从注册表中删除与此COM组件相关的所有条目和ProgID'Log.Main',或者是否有其他注册表清理工具可用的工具。

This is not generally possible unless you still have the original component. 除非您仍拥有原始组件,否则通常无法进行此操作。 The ProgId only gives you the entry in the Classes registry key, the CLSID {guid}. ProgId只为您提供Classes注册表项中的条目,即CLSID {guid}。 You will not be able to find the entries in the TypeLib and Interface registry keys because you do not know their {guid}s. 您将无法在TypeLibInterface注册表项中找到条目,因为您不知道它们的{guid}。

To avoid registry pollution, it is pretty important to unregister the component first before you rebuild it. 为避免注册表污染, 重建组件之前首先取消注册该组件非常重要。 That's done automatically by MSBuild when you use the "Register for COM interop" option, available in a .NET project on the Project + Build tab property page. 当您在Project + Build选项卡属性页上的.NET项目中使用“Register for COM interop”选项时,MSBuild会自动完成此操作。 With the quirk that you need to run VS elevated so MSBuild can monkey with the register, right-click the shortcut and choose Run as Administrator. 有了你需要运行VS提升的怪癖,所以MSBuild可以使用寄存器,右键单击快捷方式并选择以管理员身份运行。

If that is unpractical for some reason then you can find some relief by using the [Guid] attribute explicitly so the type library, interface and class guids are always the same. 如果由于某种原因这是不切实际的,那么你可以通过显式使用[Guid]属性来找到一些解脱,所以类型库,接口和类guid总是相同的。 It is however very, very important to remove them again when you are done debugging and testing the component or you risk very serious DLL Hell when you make changes. 但是,当您完成调试和测试组件时,再次删除它们非常非常重要,否则当您进行更改时风险非常严重的DLL Hell。 Strongly favor MSBuild doing this automatically for you. 非常赞成MSBuild为您自动执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM