简体   繁体   中英

Do I need to un-register previous DLL before registering new version

I have a .Net DLL which I want to register using regasm . I am fairly new to C#.

Lets say that I have to upgrade my DLL and the old DLL is already registered. Do I need to un-register the old DLL before registering the new one?

Thanks,

Yes, important. If not to catch mistakes in a client app using an old version your DLL, then at least to prevent your registry collecting junk entries that are pretty hard to get rid of.

You should very strongly favor MSBuild taking care of this automatically so you can never forget. Project + Properties, Build tab, tick the "Register for COM interop" option. That not only registers the assembly, it also ensures that an existing DLL gets unregistered before the build starts and overwrites the DLL. The only requirement for this option is that you run VS elevated so that the build system has write access to the registry. Right-click the shortcut on your desktop and click "Run as Administrator" to trigger the UAC prompt.

If you are not using this for some reason then it gets to be important to use the [Guid] attribute on any [ComVisible] interface or class. Which ensures that the registry keys are always the same so you don't get hurt too much by forgetting to register or forgetting to cleanup. It is however very, very important that you remove them again when you're done testing your code. Forgetting to do so causes a particularly nasty kind of DLL Hell if you are unsure of COM versioning requirements.

如果未更改CLSID,则无需注销旧的CLSID。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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