简体   繁体   English

COM-Interop:将.NET Framework版本从2.0更改为4.0 - 我是否也应该更改Guids?

[英]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. 我喜欢将COM-Class从2.0迁移到4.0。 Would you recommend also to generate new guids for the classes and a different ProgId? 您是否还建议为类和不同的ProgId生成新的guid?

The old Class would not be used anymore. 旧的课程将不再使用。 I know I have to re-register the Class, for the new Path of the mscorlib. 我知道我必须为mscorlib的新路径重新注册Class。

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) MS-Access使用CreateObject创建一个我的COM-Server类的实例,我的COM-Object使用DI加载一些其他类(dot.net 2.0和将来的4.0)

You only have to use new GUIDs when the interface definition changes. 您只需在接口定义更改时使用新的GUID。 When you keep them the same, your new COM server will replace the existing one. 当它们保持不变时,新的COM服务器将替换现有的COM服务器。 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. 请注意,.NET 4.0中的进程内并行CLR版本支持与此相关。 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. 您的COM服务器可以在绑定.NET 4.0 CLR的程序中使用,即使COM服务器仍然绑定2.0 CLR。 Technically you don't have to update it. 从技术上讲,您不必更新它。

I don't see why you would change the Guid or the progid. 我不明白你为什么会改变Guid或者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并进行了一些测试。 DOT.net 4.0 can use 2.0 Assemblies, no problem for my DI Scenario. DOT.net 4.0可以使用2.0程序集,对我的DI场景没问题。

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. 原因是,因为HKEY_CLASSES_ROOT \\ CLSID {COMGuid}控制了它必须使用的运行时版本。

"RuntimeVersion"="v4.0.30319" “RuntimeVersion”= “v4.0.30319”

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

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