VS2008 Multitargeting Gets Even Better with SP1

One of my favorite features of VS2008 is the ability to target older versions of the .NET Framework.  This allows developers to use the latest and greatest tools even if some client machines can't be upgraded to the latest version of framework right away.

While there is really good support for this in VS2008 for example, VS 2008 is smart enough to keep you from adding a reference to assemblies that are not found in the target version of the framework (for example, you can't use WPF if your target framework is .NET Framework 2.0).    But what about the case when new methods are added to existing classes or new classes in existing assemblies?  For example the DateTimeOffset?  

For those we added a new FxCop rule in VS2008SP1... I highly recommend you use this if you are cross targeting.

David Kean has the full play by play, but basically you enable the rule in VS


And select your target framework


Then if you use some new types of members, you get this warning.

'Use only API from targeted Framework' warning

Of course this works for the standard alone version of FxCop as well.

Check out David's blog for all the details!

Comments (7)

  1. Awesome info. Just one small comment, maybe mention that it will only apply to VSTFS however I do wish there was a way to plug FxCop into Professional, similar to the way StyleCop does.

  2. Eddie Velasquez says:

    I guess you meant DateTimeOffset, not DateTimeOffsite.

  3. Rod Mac says:

    Great stuff. Am just going to keep nagging MS and say SL should come in 2 flavours – one for Windows machines & one for crossbrowser everything else. And guess what, the Windows version is a true subset of .NET and hence would be an even lighter client .NET distributable, the stuff that XBAPs would really have been made of with a lot of hindsight – no criticism intended here, the initial hoop had to be iterated. Of course multitargeting would control the SL boundary for Windows boxes, and a recompilation would create a 2nd build for non windows SL deployment.

  4. My latest in a series of the weekly, or more often, summary of interesting links I come across related to Visual Studio. Sara Ford’s Tip of the Day #305 shows how to reevaluate expressions in the QuickWatch window . Brad Abrams explains how VS208 Multitargeting

  5. 【原文地址】 VS2008 Multitargeting Gets Even Better with SP1 【原文发表日期】 02 September 08 09:53 我在VS2008中最喜爱的特性之一

  6. Одной из моих любимых особенностей VS2008 является возможность использования старших версий .NET framework….

Skip to main content