tags:

views:

149

answers:

3

Consider I am having two versions of .Net(.Net 1.1,2.0) in my developement machines. If I am deploying my application X against .Net 1.1 and deploying another applicatin Y agaings .Net 2.0 framework.

Now I need to know in which CLR(1.1 or 2.0) my both applications will run?

Also state me the reason?

+1  A: 

From Visual Studio 2008 onwards, you can target a specific version of the .Net Framework - 2.0, 3.0 or 3.5

Before VS2008, its fixed -

VS2005 targets .Net Framework v2.0

VS2003 targets .Net Framework v1.1

VS2002 targets .Net Framework v1.0

If you specify the target, it will require THAT perticular version of the .Net Framework.

CORRECTION: It will run on THAT version or a higher, compatible one.

It won't require that particular version. For example, an application built with VS2003 may target v1.1, but can still run if 1.1 isn't installed but 2.0 is.
Jon Skeet
Oh yeah.. what I should have said was - The minimum requirement would be that version.
@Jon... I remembered just now - I think that's not quite true OR it could be an exception case. I tried running Quake2.net - a C -> C++ and then C++ - managed C++ port by Vertigo. It required .Net 1.1. I had .Net 2.0 installed but it specifically demanded v1.1. Why is that? One more app did that - FotoVision - also from Vertigo. And it wasn't the case for other apps - apps I wrote, targeting v2.0 ran fine in systems which only had v3.5! What is going on?
+12  A: 

This MSDN article explains it all fairly clearly:

The version of the .NET Framework that an application runs on is determined as follows:

  • If the version of the .NET Framework that the application was built against is present on the computer, the application runs on that version.

  • If the version of the .NET Framework that the application was built against is not present and a configuration file does not specify a version in a <supportedRuntime> Element, the application runs on the latest version of the .NET Framework that is present on the computer.

  • If the version of the .NET Framework that the application was built against is not present and the configuration file specifies a version in a <supportedRuntime> Element, the application runs on the latest version that is specified in the application configuration file and is present on the computer.

As Sam mentions in the comments, one exception to this is ASP.NET, where the version used is specified in the IIS management console.

Jon Skeet
@Jon, there is one important edge case which is missing, if its an ASP.Net application the version of the framework targeted is specified in IIS
Sam Saffron
Thanks - will edit.
Jon Skeet
Another edge case, SQL CLR will only work on .Net 2.0
Sam Saffron
+2  A: 

Just to add to the replies above: if you're talking asp.net apps it changes all play rules. Besides the framework config option in iis manager, the framework is loaded per app pool so you must ensure that all apps sharing an app pool uses the same framework version.

KristoferA - Huagati.com