简体   繁体   English

.NET Framework版本和COM对象

[英].NET Framework version and COM objects

We have an MFC applcation EXE that hosts COM objects which are the main parts of the application, this is so we can dymanically build in more functionality. 我们有一个MFC应用程序EXE,它承载着COM对象,这些对象是应用程序的主要部分,因此,我们可以动态地构建更多功能。 Lately new code has been created using C# and made COM visible supporting the same interface. 最近,使用C#创建了新代码,并使COM可见,从而支持相同的接口。 These have all typically been built against V2.X .Net runtime. 这些通常都是针对V2.X .Net运行时构建的。 We now want to be able to deploy on a client machine that may only have V4.X .Net runtime but we want to maintain compatability with the V2.X code. 现在,我们希望能够在仅具有V4.X .Net运行时的客户端计算机上进行部署,但是我们希望保持与V2.X代码的兼容性。 If the main application had been a .Net application then we could have used in the config file. 如果主应用程序是.Net应用程序,那么我们可以在配置文件中使用它。 This doesn't work with a non .Net host application. 这不适用于非.Net主机应用程序。

Does anyone know if the same can be done for the .Net COM components, ie specify somewhere that they can run on v4.X without having to re-build and re-target them? 有谁知道是否可以对.Net COM组件执行相同的操作,即指定一个可以在v4.X上运行的位置,而无需重新构建和重新定位它们?

What v4.x runtime? 什么v4.x运行时? latest framework version is 3.5 and that does not contain changes to the runtime. 最新的框架版本是3.5,并且不包含对运行时的更改。 It's the same runtime as 2.0 with some additional libraries. 带有一些其他库的运行时与2.0相同。

I found the answer, you need to put a bit more in the app.exe.config file, see below 我找到了答案,您需要在app.exe.config文件中添加更多内容,请参见下文

<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <requiredRuntime safemode="true" imageVersion="v4.0.21006" version="v4.0.21006"/>
        <supportedRuntime version="v4.0" sku="client" />
    </startup>
</configuration>

This then allows unmanaged host exe files to launch managed components that are not built against the target v4 runtime. 然后,这将允许非托管主机exe文件启动不是针对目标v4运行时构建的托管组件。

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

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