views:

1893

answers:

4

I have some DLLs that it would be much easier to use .net 3.5 internally (to take advantage of Linq, etc). I want to use these DLL with asp.net websites that are currently running asp.net 2.0.

Is this scenario possible? Are there any restrictions or gotchas (e.g. asp.net doesn't make any calls to methods which return .net 3.5 objects like IQueryable)?

Note: Of course, .net 3.5 will be installed on the server.

+3  A: 

You can use many features of C# 3 in .net 2.0, but Linq is not one of them. You have to include the Linq DLL's, which you are not allowed to distribute seperately and must install the full 3.5 runtime.

NOTE: If .net 3.5 is installed, I think you will have trouble if the site is not configured to include assemblies from 3.5. It may work in a Web Application project (as opposed to a Web Forms project) since the dll's are compiled beforehand and may include the necessary references in the PE files, but i'm not sure.

Mystere Man
So if I install a 3.5 dll and call only 2.0 compatible methods, it will work?
Keltex
+2  A: 

3.5 adds to the 2.0 framework, everything is fully backwards compat.

Adam Fyles
But if 3.5 is not installed, then you cannot make use of 3.5 features. For instance, .net 3.5 will not install on Windows 2000, but .net 2.0 will. So it's not fully backwards compatible.
Mystere Man
+2  A: 

There's always LinqBridge, which allows you to use Linq To Objects in a .Net 2.0 environment. However there are some caveats around using it with ASP.Net, depending on whether you use ASP.NET Web Application or ASP.NET Web Site projects. See this page for more information.

Stuart Dunkeld
+3  A: 

To expand on what foosnazzy said, .NET 3.5 (SP1) is just .NET 2.0 SP2 with some new assemblies. The only reason not to install it on the web site would be if the web site would not run with .NET 2.0 SP2.

This is very different from the way it used to be - installing .NET 1.1 on a .NET 1.0 web site I was responsible for broke the web site, even though the web site wasn't using 1.1 - I had installed 1.1 so I could use a particular tool. The upgrade from .NET 1.1 to .NET 2.0 was an even worse nightmare.

But Microsoft learned from this. .NET versions from 2.0 .NET 3.5 SP1 all use the .NET 2.0 Common Language Runtime (CLR). In fact, people who have installed 3.5 are often surprised to look at the IIS settings and see that their web sites still show as running .NET 2.0. But it's the exact same .NET 2.0, just with two service packs applied. Any site that doesn't use the new assemblies can't be affected at all (beyond what a service pack might do).

To further reiterate what has been said - the C# 3.0 features are independant of the Framework. For instance, you can use anonymous types and lambdas in pure .NET 2.0 code. What you can't do is use LINQ, since that requires the new assemblies in .NET 3.5.

John Saunders