Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use a .net 3.5 DLL with a .net 2.0 website?

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.

like image 250
Keltex Avatar asked Apr 01 '09 22:04

Keltex


People also ask

Can multiple .NET versions coexist?

Microsoft designed the . NET Framework so that multiple versions of the framework can be installed and used at the same time. This means that there will be no conflict if multiple applications install different versions of the . NET framework on a single computer.

Are .NET versions backwards compatible?

The . NET Framework 4.5 and later versions are backward-compatible with apps that were built with earlier versions of the . NET Framework. In other words, apps and components built with previous versions will work without modification on the .

Is .NET 3.5 still needed?

You may need the .NET Framework 3.5 to run an app on Windows 11, Windows 10, Windows 8.1, and Windows 8. You can also use these instructions for earlier Windows versions.

Can I install multiple versions of .NET Framework?

It is safe to install multiple versions of the . NET Framework on your computer.


1 Answers

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.

like image 109
John Saunders Avatar answered Sep 28 '22 18:09

John Saunders