How does .NET/COM work with multiple versions registered via Regasm?

◇◆丶佛笑我妖孽 提交于 2019-12-05 04:29:55

I always set my COM visible assemblies up with a static AssemblyVersion for just this reason. If you want to have binaries tagged with a version, use AssemblyFileVersion instead.

  1. Last registered object wins: yep
  2. Not really. You can put stuff in your assembly's ComRegisterFunction/ComUnregisterFunction attributed methods to automate the cleanup, but if you leave old version droppings around, this is about the only way.
  3. You'd do it with a different coclass GUID and/or ProgID (eg, MyCoClass.1, .2, etc). CoCreateInstance doesn't know anything about the version values- they're used by the CLR's activator to ensure it loaded the right assembly.
  4. No- best thing to do is never change your assembly version (see above).

Components with the same CLSID should be compatible, especially if you've only changed the build number between assemblies. Here's the only relevant thing I found to confirm this by googling quickly.

To answer your questions directly:

  1. Correct.
  2. regasm /unregister
  3. Look into Binding redirects.
  4. Probably not.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!