views:

228

answers:

2

I have a basic doubt that, How can we have both CLR's on a same machine. If this is possible, When I refer few dll's of 4.0 and setting application pool to 2.0 why Cant I run the website(I am getting errors).When we refer the dll's from web.config it means it searches for GAC when that particular 4.0 dll is available in GAC Why dont it load (How come it is not loading).. Please clarify my doubts

+3  A: 

Application pools are set to run a specific version of the framework. It uses this information to determine which assembly to load from GAC.

You can't load a .NET 4 assembly from a 2.0 application/process.

You can have 1.0, 1.1, 2, 3, 3.5 and 4 all installed side-by-side.

Michael Shimmins
+5  A: 

Yes, both CLRs can be on the same machine - in fact, .NET 4 allows you to have the same process hosting both CLRs at the same time!

Different assemblies in the GAC will have different versions, so if your references specify the version, the CLR will load the appropriate one. Of course, you need to make sure you've got the appropriate CLR loading the appropriate assembly; while the v4 CLR can load v2 assemblies (with some restrictions, IIRC), you shouldn't try to load a v4 assembly from the v2 CLR.

As for why you're having problems - that's really impossible to say without more information. (Any time you ask a question and you have an error, say what that error is.)

Jon Skeet
My answer way be wrong then - I thought CLR versions were isolated. Has this changed?
Michael Shimmins
@Michael: What sort of isolation were you thinking of? I believe you can use a class library built targeting .NET 2.0 when running a .NET 4 application, for example - would you not have expected that to work? IIRC there are some restrictions around native code though; mixed mode assemblies need to be rebuilt.
Jon Skeet
Hi Jon Skeet, The problem i am facing is, I am trying to run a website with application pool is pointing to 2.0 and the web.config of that webisite is pointing to some of the 4.0 dll's, So I am getting error that could not load an assemly. But My doubt is even the GAC has those dll's Y can't it load them.
Vinni
@Vinni: I suggest you just point the application pool at 4.0 instead.
Jon Skeet
@Jon - never mind, I had a brain fart. I was thinking that you were saying 2.0 could load 4.0 DLLs.
Michael Shimmins