简体   繁体   中英

.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. Lately new code has been created using C# and made COM visible supporting the same interface. These have all typically been built against V2.X .Net runtime. 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. If the main application had been a .Net application then we could have used in the config file. This doesn't work with a non .Net host application.

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?

What v4.x runtime? latest framework version is 3.5 and that does not contain changes to the runtime. It's the same runtime as 2.0 with some additional libraries.

I found the answer, you need to put a bit more in the app.exe.config file, see below

<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.

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