rohancragg
rohancragg

Reputation: 5156

How to do forward-compatibility for .NET 3.5 features in .NET 2.0 apps?

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...

Upvotes: 2

Views: 1772

Answers (2)

ljs
ljs

Reputation: 37837

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.

Upvotes: 1

StingyJack
StingyJack

Reputation: 19479

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.

Upvotes: 0

Related Questions