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

image

And select your target framework

image

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

  • Anonymous
    September 02, 2008
    PingBack from http://hoursfunnywallpaper.cn/?p=4227

  • Anonymous
    September 02, 2008
    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.

  • Anonymous
    September 02, 2008
    I guess you meant DateTimeOffset, not DateTimeOffsite.

  • Anonymous
    September 02, 2008
    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.

  • Anonymous
    September 07, 2008
    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

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

  • Anonymous
    October 13, 2008
    Одной из моих любимых особенностей VS2008 является возможность использования старших версий .NET framework....