views:

267

answers:

5

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

A: 

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.

Mahin
"Auto properties" are a feature of the C# 3 compiler, not the .net 3.5 libraries. You can still use auto properties if you use the C# 3 compiler even if you target the .net 2.0 libraries.
Jason Williams
A: 

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

Stuart
+2  A: 

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.

Pete OHanlon
+6  A: 

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.

Jason Williams
+2  A: 

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.

Jon Skeet