How to unregister my .net assembly when it's no longer in the same location?

三世轮回 提交于 2019-12-21 04:59:19

问题


I have a dll that's registered for com interop, so under HKLM\Software\Classes\CLSID[my guid]\InprocServer32[my version no]\Codebase it has the path of the registered dll. However, I've rearranged my folder structure so that path is no longer correct. Is there a way of unregistering that dll without putting it back, then unregistering, then removing the file again?

And what if I don't have that dll any more, or only have one with a different version number?


回答1:


Different version numbers (generally) do not matter. As long as the newer DLL contains all the GUIDs which appear in the older version, it will be unregistered properly (using the new one with regasm,exe). And of course, reregistering the assembly for COM interop will properly relocate necessary registry keys.




回答2:


As far as I know - all you need is to register the DLL in it's new location.
You can use MS tool oleview.exe to verify the COM registration points to the correct location.




回答3:


The problem we encountered with just registering the new dll is when it's got a lower version to the previously-registered one. You end up with this in the registry:

HKCR\MyLib.MyClass\CLSID:(Default)=<my guid>

and 

HKCR\CLSID\<my guid>:Assembly=<string containing version number> 

and 

HKCR\CLSID\<my guid>\InprocServer32\<version number>\ ... more details

I think the runtime will try to load the assembly identified in HKCR\CLSID\<my guid>:Assembly, so you want to try to unregister that one if possible.

This isn't an answer about how to unregister it, but if you can't unregister that I've found it useful to get in there and remove the key for the version number you no longer have, and probably update the Assembly value manually if you dare.



来源:https://stackoverflow.com/questions/455073/how-to-unregister-my-net-assembly-when-its-no-longer-in-the-same-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!