Question

Our codebase where I work is .NET 2.0. For our new assembly/DLLs/web applications I would love to take advantage of what 3.5 has to offer.

Can one mix .NET frameworks(per assembly) in a solution? Are there any IIS related caveats to this?

I would love to hear any positive/negative/howto feedback. Let me know!

Thanks!

Was it helpful?

Solution

Yes you can do this in Visual Studio and it is called Multi-Targeting.

Scott Guthrie has a great blog-entry on Multi-Targeting Support in Visual Studio.

VS 2008 was the first release of Visual Studio that included multi-targeting support for .NET. What this meant was that you could use VS 2008 to create and edit not only .NET 3.5 projects, but also .NET 3.0 and .NET 2.0 projects as well. This allowed developers to more quickly upgrade and take advantage of new Visual Studio tooling features – without having to necessarily require the newer version of .NET to be installed on the clients and production servers running their applications.

Cheers

OTHER TIPS

You can use 2.0, 3.0 and 3.5 together according to: http://msdn.microsoft.com/en-us/library/bb383796(v=vs.90).aspx

EDIT: I was wrong you can. You can go reference 3.+ assemblies in 2.0, because the CLR is the same. This will not be the case when going from 2.0/3.+ to 4.0 as there is a new version of the CLR.

http://abdullin.com/how-to-use-net-35-syntax-and-compiler-features-for-net-20/

If you can wait for the new .NET 4.0 framework, you will be able to run dll's for each version side by side in the same process.

This should not be an issue. .NET 2.0 RTM through .NET 3.5 SP2 all use the exact same version of the CLR. They only differ by the number of assemblies that are included. The assembly format is the same. Of course, if you do take advantage of an assembly that's only included with .NET 3.5, you must make sure that 3.5 is actually installed on the target machine. You'll find out quickly if it isn't.

3.5 should already be on the machine if it has Windows Update enabled. If not, it takes a dozen or so minutes to get it on there.

As a side note, we have some old 1.0 libraries that we used in 2.0 and still use in 3.5, without recompiling. So there's some backwards compatibility there.

You cannot have .Net 1.1 assmeblies running in the same process as a .Net 2.0+ assembly - attempting to do so will produce a failure.

With regards to IIS, this means that you cannot have .Net 1.1 sites / virtual directories running in the same application pool as .Net 2.0 and above sites - you need to create a separate app pool to keep the .Net 1.1 code running in a different process. (This can only be done in IIS 6.0 and above, i.e. not in Windows XP)

However as nobugz says - .Net 2.0 through to .Net 3.5 all use the same CLR, and so different versions of .Net code can be mixed in the same assembly without worry - this also holds true for IIS (.Net 2.0 and .Net 3.5 code can happily co-exist in the same app pool)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top