views:

1161

answers:

2

I want to start using .NET 3.5 features in an app that is currently stuck in the past - how can I write in support for selected features like JSON serialization in a forward-compatible way?

In the case of JSON serialization I need to reference System.ServiceModel.Web - is it OK to reference a .NET 3.5 dll in a VS2005 app? Presumably this is in the GAC but on a deployment environment it may not be...

A: 

You can reference any DLL you want, but you may want to explore the reference property setting "Copy Local=True" if you are not going to require the version of framework that the dll came from.

StingyJack
+1  A: 

Referencing a .NET 3.5 DLL is not a good idea if your application targets .NET 2.0, as the library you're referencing will likely reference other .NET 3.5 libraries that will not be available on a user's computer if they do not have the .NET 3.5 runtime installed.

You can set your project to target .NET 3.5 if you like (from Project Properties|Application|Target Framework) which will overcome this problem - your app will then use its currently referenced .NET 2.0 libraries (as well as any .NET 3.5 libraries you want to add to use for new code), while requiring .NET 3.5 on users' machines allowing the use of the DLL.

kronoz
The only comment I have on this great answer is that I am sadly still using VS2005 so I cannot target a version of the framework, but this is a good reason to push to migrate to VS2008 even if we mostly stick to .NET 2.0.
rohancragg