tags:

views:

185

answers:

2

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, i.e. specify somewhere that they can run on v4.X without having to re-build and re-target them?

A: 

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.

AZ
Hi, thanks for response, we are using .Net Framework 4 Beta 2 (Client Profile as it happens), it ships with a new runtime of V4.0
Maybe i'm wrong but as I am aware .NET 4 will not be changing the CLR runtime but instead will deliver the DLR witch is added to support dynamic languages.
AZ
AZ - .Net framework 4.0 is actually a new runtime (in addition to DLR features you mentioned). See http://www.infosysblogs.com/microsoft/2008/11/net_framework_40_clr_enhanceme.html for more information (first link I found on Bing with good information). There's also a link to a nice PDC2008 presentation in there.
Doug Rohrer
A: 

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.

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