views:

1236

answers:

2

When adding a reference to a project I sometimes see the message...

"The Target Framework version for the project is higher than the current project Target Framework version. Would you like to add this reference to your project anyway?"

I understand what the message is indicating but can anyone explain what issues might arise from saying 'Yes'?

+4  A: 

Suppose you build an application where the exe targets 2.0, but some library targets 3.5. Someone with a .NET 2.0 machine looks at the main project and thinks they can run it - after all, the application targets 2.0, right? When the library is first loaded, they'll get a nasty surprise...

Jon Skeet
But somehow this was Ok to compile in VS2008, VS2010 all of a sudden refuses to build such projects. It is a very common scenario when having additional references in debug builds.
Johannes Rudolph
A: 

Actually, this is perfectly fine. VS is just making you aware. Just make sure you copy the necessary references to your project and reference them. If the project you are referencing is one that you have control over you can put the references in there.

For instance, we have an older Windows 2000 server that cannot run .Net 3.5. So, when we want to take advantage of things like LINQ we builg that into a separate project that targets 3.5. We then reference that project from our web app, which targets 2.0. We get the message you talked about but we just make sure the System.core and Link.Data DLLs are copied to the bin folder and referenced. Then there is no issue. Works like a charm.

Matt Penner