Tomek
Tomek

Reputation: 3279

Accessing .Net 3.5 assemblies from .Net 2

Visual Studio gives a warning when trying to do that, but does not prevent it. Is it safe and what are the implications?

Upvotes: 0

Views: 722

Answers (5)

Jon Skeet
Jon Skeet

Reputation: 1500765

How do you know which other .NET 3.5 assemblies the ones you reference directly will need? You don't know whether they'll rely on registry entries written by the .NET 3.5 installer, or on the CLR 2.0 SP1 changes.

Basically it's a really bad idea, IMO. If you want to use .NET 3.5, just install .NET 3.5. Anything else is just asking for really hard to diagnose problems.

Upvotes: 2

Jason Williams
Jason Williams

Reputation: 57902

If you use .net 3.5 libraries in any way, then you are using .net 3.5. You are not using them "from .net 2.0", you are simply using .net 3.5 and will need to distribute the .net 3.5 runtime with your applicaiton.

Upvotes: 6

Pete OHanlon
Pete OHanlon

Reputation: 9146

As you are probably aware, .NET 3.5 is an incremental change to the language building on features first introduced in .NET 2. This means that you can multi-target to .NET 2, .NET 3 and .NET 3.5. .NET 3 and .NET 3.5 brought some fairly fundamental enhancements by introducing new DLLs and uprating some of the existing ones to cope with new language features such as LINQ and Lambda expressions.

From the previous paragraph, we can deduce that using .NET 3.5 assemblies from a .NET 2 application is perfectly possible, but the deployment implications means that you have to distribute the DLLs that are appropriate to .NET 3.5. This means that you'll probably end up having to use the .NET 3.5 redistributable.

Upvotes: 2

Stuart
Stuart

Reputation: 12215

make sure you only reference .net 2.0 assemblies from a .net 2 application. When you deploy your application, if the assemblies are not loaded on the server your application will fail

Upvotes: 0

MRG
MRG

Reputation: 3219

You can use .Net 3.5 features like short get set properties, if you make sure you have selected compiler to output .Net 2.0 code.

Upvotes: 0

Related Questions