tags:

views:

165

answers:

3

This is pretty obvious I think but I thought it better to ask:

If an application (exe) is compiled to run on .net 3.5 and if the dlls it uses are compiled for .net 1.1 will the DLL automatically use the 2.0 CLR, i.e the parents?

What about vice versa?

If so, what about compatibility issues?

+1  A: 

No. If you target the 3.5 version framework, it ill not magically use the 2.0 if 3.5 is not present.

But you can use assemblybinding bindingredirect in the app.exe.config to specify a replacement version:

<configuration>

   ....

  <runtime>
    <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentassembly>
        <assemblyidentity name="System" culture="neutral" publickeytoken="969db8053d3322ac" />
        <bindingredirect newVersion="2.0.0.0" oldVersion="1.0.5000.0" />
      </dependentassembly>
      <dependentassembly>
        <assemblyidentity name="System.Windows.Forms" culture="neutral" publickeytoken="969db8053d3322ac" />
        <bindingredirect newVersion="2.0.0.0" oldVersion="1.0.5000.0" />
      </dependentassembly>      
    </assemblybinding>
  </runtime>

</configuration>

See Redirecting Assembly Versions

Mitch Wheat
Mitch. Your answer is not clear. Are you saying that the DLL WONT use the parents runtime? If not, are 2 CLRs loaded?
Bobby Alexander
@Bobby Alexander: could you clarify your question please.
Mitch Wheat
Mitch, What I wanted to know was this: If an exe is built for framework 3.5 but the DLLs it uses (references) are built on .net 1.1, will the dlls automatically run on 2.0 CLR (same as the parent)?
Bobby Alexander
A: 

If your application uses framework 3.5 (which is really CLR 2) and it loads dlls compiled for CLR 1.0 or CLR 1.1 then these dlls will automatically use CLR 2. You can not go the other way - ie. you can not load a CLR 2 dll into a CLR 1 process without some hurt.

In CLR 4 these rules change a bit as you can now have multiple CLR instancs in a given process, this is however only relevant if you instantiate objects through COM, not if you load through normal reflection.

S.Skov
+1  A: 

It is the EXE file that decides what .NET runtime version the process will use. Any assemblies compiled for earlier versions of .NET will have to use "process version". This usually works as .NET has had very few breaking changes.

A .NET 3.5 application using a .NET 1.1 DLL will run that DLL on the CLR 2.0 (.NET 2.0, 3.0 and 3.5 all uses the same CLR 2.0 version).

.NET 4 has a new CLR and one of the new features of .NET 4 is in-process side by side CLR hosting that allows multipe versions of.NET in the same process and that may change the answer..

Arve
Arve, which framework dlls will they use? I mean, if the 1.1 dlls are running on 2.0 CLR, will it use the parents framework dlls (3.5) or the one it is built on (1.1)?
Bobby Alexander