VS2010 Gotcha: Inadvertently targeting the wrong framework

I love VS2010’s multi-framework targeting feature, yet it has bitten me in the rear-end more than once.

The problem is that I have created projects in .NET 3.5 without realizing it, then at some point, when something doesn’t work as expected, if I’m lucky I discover the mistake.

Typically, this happens after you have explicitly chosen .NET 3.5 as the target framework. Then every project after that will be .NET 3.5 until you explicitly choose .NET 4.0 again.

This morning that wasn’t the case. I was workign with a brand new installation of VS2010 RC and created a new class library then added to it an entity data model.

All of the features worked as expected except that I couldn’t generate a new code generation item.

Finally when I created a console app and attempted to add a reference to System.Data.Entity, I noticed that I was only seeing 3.0 and 3.5 versions of assemblies in the Add Reference dialog and realized my mistake (of creating the .NET 3.5 project).

This was in the middle of recording a session of DNRTV so turns out to be a really good lesson for viewers.

But I sure wish Visual Studio 2010 would warn me when I am creating a non .NET 4.0 project.

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.