简体   繁体   中英

COM-Interop: Change .NET Framework Version from 2.0 to 4.0 - Should I change the Guids also?

I like to migrate a COM-Class from 2.0 to 4.0. Would you recommend also to generate new guids for the classes and a different ProgId?

The old Class would not be used anymore. I know I have to re-register the Class, for the new Path of the mscorlib.

MS-Access create an instance auf my COM-Server Class with CreateObject and my COM-Object load some other classes with DI (dot.net 2.0 and in future 4.0)

You only have to use new GUIDs when the interface definition changes. When you keep them the same, your new COM server will replace the existing one. And client code that uses it doesn't have to be recompiled. When you do change them then they can live side-by-side but client code has to explicitly be recompiled to use the new one.

Note that the in-process side-by-side CLR version support in .NET 4.0 is relevant here. Your COM server can be used in a program that binds the .NET 4.0 CLR, even if the COM server still binds the 2.0 CLR. Technically you don't have to update it.

I don't see why you would change the Guid or the progid. It means you would have to recompile everything that this references.

As long as you stick to binary compatability , it doesn't matter what version of the framework the implementation of your contract is, it's simply that, an implementation detail.

I migrated to DOT.net 4.0 and do some tests. DOT.net 4.0 can use 2.0 Assemblies, no problem for my DI Scenario.

The Only thing I have to do, is update my installer. The reason for this is, because the HKEY_CLASSES_ROOT\\CLSID{COMGuid} controls witch Runtime Version it have to use.

"RuntimeVersion"="v4.0.30319"

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