<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://davesbox.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Dave's Box : Compatibility</title><link>http://davesbox.com/archive/tags/Compatibility/default.aspx</link><description>Tags: Compatibility</description><dc:language>en</dc:language><generator>CommunityServer 2008 (Build: 30417.1769)</generator><item><title>Documenting ‘undocumented’ features</title><link>http://davesbox.com/archive/2008/12/29/documenting-undocumented-features.aspx</link><pubDate>Mon, 29 Dec 2008 15:00:00 GMT</pubDate><guid isPermaLink="false">2122c344-89bc-4cd7-b145-b0515ba3439f:1099</guid><dc:creator>David Kean</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/rsscomments.aspx?PostID=1099</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/commentapi.aspx?PostID=1099</wfw:comment><comments>http://davesbox.com/archive/2008/12/29/documenting-undocumented-features.aspx#comments</comments><description>&lt;p&gt;MMayerl &lt;a href="http://msdn.microsoft.com/en-us/library/x53a06bb.aspx#CommunityContent"&gt;asks over on the MSDN wiki&lt;/a&gt;,&amp;nbsp;why we don&amp;rsquo;t document the undocumented C# keywords &lt;em&gt;&lt;strong&gt;__makeref&lt;/strong&gt;&lt;/em&gt;, &lt;em&gt;&lt;strong&gt;__reftype&lt;/strong&gt;&lt;/em&gt;, &lt;strong&gt;__&lt;em&gt;refvalue&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;__arglist&lt;/em&gt;&lt;/strong&gt;?&lt;/p&gt;
&lt;p&gt;Because that defeats of the purpose of them being undocumented.&lt;/p&gt;
&lt;p&gt;They are undocumented for a reason; so that the C# team is free to change and remove these keywords without worrying whether customers have taken dependencies on them. Documenting them conveys an implicit support agreement between Microsoft and the user, thereby preventing the team from ever changing the keywords. &lt;/p&gt;
&lt;p&gt;We want less people to use them, not more.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://davesbox.com/aggbug.aspx?PostID=1099" width="1" height="1"&gt;</description><category domain="http://davesbox.com/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://davesbox.com/archive/tags/Compatibility/default.aspx">Compatibility</category></item><item><title>Moving a type from one assembly to another using TypeForwardedToAttribute</title><link>http://davesbox.com/archive/2008/12/19/moving-a-type-from-one-assembly-to-another-using-TypeForwardedToAttribute.aspx</link><pubDate>Fri, 19 Dec 2008 15:00:00 GMT</pubDate><guid isPermaLink="false">2122c344-89bc-4cd7-b145-b0515ba3439f:1077</guid><dc:creator>David Kean</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/rsscomments.aspx?PostID=1077</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/commentapi.aspx?PostID=1077</wfw:comment><comments>http://davesbox.com/archive/2008/12/19/moving-a-type-from-one-assembly-to-another-using-TypeForwardedToAttribute.aspx#comments</comments><description>&lt;p&gt;One of the problems that we&amp;rsquo;re facing today in the Framework, mainly stemming from the &lt;a href="http://www.danielmoth.com/Blog/2007/06/net-framework-35.html"&gt;red bits/green bits&lt;/a&gt; design of .NET 3.5, is that certain &amp;lsquo;core&amp;rsquo; types are located in the wrong assemblies.&lt;/p&gt;
&lt;p&gt;For example, the extremely useful &lt;a href="http://msdn.microsoft.com/en-us/library/ms668604.aspx"&gt;ObservableCollection&amp;lt;T&amp;gt;&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/ms668620.aspx"&gt;ReadOnlyObservableCollection&amp;lt;T&amp;gt;&lt;/a&gt; types both live in WindowsBase.dll, which is a part of the Windows Presentation Foundation. For low-level assemblies (such as my team&amp;rsquo;s very own &lt;a href="http://www.codeplex.com/MEF"&gt;System.ComponentModel.Composition.dll&lt;/a&gt;), this means that to use types such as these, they need to take a reference to assemblies either at a higher level to themselves, or to technologies outside of their own. This is in turn leads to scary dependencies, such as the server assembly System.Web.dll&amp;rsquo;s current direct dependency on the client assembly System.Windows.Forms.dll in .NET 2.0.&lt;/p&gt;
&lt;p&gt;Going forward for .NET 4.0, the Framework Architecture team will be leading an effort (being pushed by my colleague &lt;a href="http://blogs.msdn.com/mirceat/"&gt;Mitch Trofin&lt;/a&gt;) to move these and other core types to lower-level assemblies such as mscorlib.dll and System.dll.&lt;/p&gt;
&lt;p&gt;Now, as &lt;a href="http://davesbox.com/archive/2008/12/09/quot-i-can-t-believe-microsoft-didn-t-make-enter-api-name-here-public-quot.aspx"&gt;I&amp;rsquo;ve mentioned previously&lt;/a&gt;, Microsoft takes compatibility very seriously, so you might be thinking &amp;lsquo;how can they move these types without runtime breaking changes&amp;rsquo;?&lt;/p&gt;
&lt;p&gt;Luckily, there&amp;rsquo;s already a solution for this; &lt;em&gt;type forwarding&lt;/em&gt;. Introduced in .NET 2.0, type forwarding allows assembly writers to move types into other assemblies without needing existing consumers to recompile their applications. This done via the &lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.typeforwardedtoattribute.aspx"&gt;TypeFowardedToAttribute&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To move a type, do the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Move the type from the original assembly to the assembly that will become the type&amp;rsquo;s new home.&lt;/li&gt;
&lt;li&gt;In the original assembly, add a reference to the new assembly if it does not already have one.&lt;/li&gt;
&lt;li&gt;Apply the following assembly-level attribute to the original assembly, replacing MyType with the type you moved in step 1:
&lt;pre class="code"&gt;[&lt;span style="color:blue;"&gt;assembly&lt;/span&gt;: &lt;span style="color:#2b91af;"&gt;TypeForwardedToAttribute&lt;/span&gt;(&lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af;"&gt;MyType&lt;/span&gt;))]&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Compile both assemblies and that&amp;rsquo;s it.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A couple of things to note:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The type must have the same name and namespace in the target assembly. &lt;/li&gt;
&lt;li&gt;This is considered a source breaking change; that is, users recompiling their application against the new versions of the assemblies, will be required to add a reference to the assembly that now contains the type. &lt;/li&gt;
&lt;li&gt;While fully supported by C# and C++/CLI, Visual Basic does not support moving types using the &lt;strong&gt;TypeForwardedToAttribute&lt;/strong&gt;. It does, however, support consuming assemblies written by other languages that have had their types moved. &lt;/li&gt;
&lt;li&gt;Starting in .NET 4.0, a new attribute called &lt;strong&gt;TypeForwardedFromAttribute&lt;/strong&gt; should be applied to types that have been forwarded indicating which assembly they came from. This allows runtime serialization to serialize these types correctly when interoping with previous versions of these assemblies. &lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://davesbox.com/aggbug.aspx?PostID=1077" width="1" height="1"&gt;</description><category domain="http://davesbox.com/archive/tags/BCL/default.aspx">BCL</category><category domain="http://davesbox.com/archive/tags/.NET+4.0/default.aspx">.NET 4.0</category><category domain="http://davesbox.com/archive/tags/API+Design/default.aspx">API Design</category><category domain="http://davesbox.com/archive/tags/Compatibility/default.aspx">Compatibility</category></item><item><title>"I can't believe Microsoft didn't make [Enter API Name Here] public"</title><link>http://davesbox.com/archive/2008/12/09/quot-i-can-t-believe-microsoft-didn-t-make-enter-api-name-here-public-quot.aspx</link><pubDate>Tue, 09 Dec 2008 15:00:00 GMT</pubDate><guid isPermaLink="false">2122c344-89bc-4cd7-b145-b0515ba3439f:1027</guid><dc:creator>David Kean</dc:creator><slash:comments>29</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/rsscomments.aspx?PostID=1027</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/commentapi.aspx?PostID=1027</wfw:comment><comments>http://davesbox.com/archive/2008/12/09/quot-i-can-t-believe-microsoft-didn-t-make-enter-api-name-here-public-quot.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://codebetter.com/blogs/jeremy.miller/"&gt;Jeremy Miller&lt;/a&gt; takes a dig at the &lt;a href="http://blogs.msdn.com/bclteam/"&gt;BCL team&lt;/a&gt; with his post, &lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/12/04/i-love-ayende-and-oss.aspx"&gt;I love Ayende (and OSS)&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;From one of &lt;/em&gt;&lt;em&gt;Ayende&lt;/em&gt;&lt;em&gt;&amp;#39;s many OSS projects.&lt;/em&gt; &lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color:gray;"&gt;/// &lt;/span&gt;&lt;span style="color:green;"&gt;This class actually already exists in the System.Core assembly...as an internal class.
&lt;/span&gt;&lt;span style="color:gray;"&gt;/// &lt;/span&gt;&lt;span style="color:green;"&gt;I can only speculate as to why it is internal, but it is obviously much too dangerous
&lt;/span&gt;&lt;span style="color:gray;"&gt;/// &lt;/span&gt;&lt;span style="color:green;"&gt;for anyone outside of Microsoft to be using... &lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&lt;em&gt;And dear MS BCL team, since so many people are already using Reflector to go get the ExpressionVisitor code, would you just make this public?&amp;nbsp; &amp;#39;K, thx.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This seems like an oversight that this wasn&amp;#39;t public in first place. It would just be a couple minutes of a single developer&amp;#39;s time to change the accessibility from internal to public, right?&lt;/p&gt;
&lt;p&gt;Well, actually, it&amp;#39;s &lt;em&gt;a lot&lt;/em&gt; more complicated than that. There&amp;#39;s very good reasons we don&amp;#39;t make things public and virtual by default; Eric Lippert summarizes it pretty well with his post, &lt;a href="http://blogs.msdn.com/ericlippert/archive/2003/10/28/53298.aspx"&gt;How many Microsoft employees does it take to change a lightbulb?&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;One dev to spend five minutes implementing ChangeLightBulbWindowHandleEx. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One program manager to write the specification. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One localization expert to review the specification for localizability issues. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One usability expert to review the specification for accessibility and usability issues. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;At least one dev, tester and PM to brainstorm security vulnerabilities. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One PM to add the security model to the specification. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One tester to write the test plan. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One test lead to update the test schedule. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One tester to write the test cases and add them to the nightly automation. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Three or four testers to participate in an ad hoc bug bash. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One technical writer to write the documentation. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One technical reviewer to proofread the documentation. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One copy editor to proofread the documentation. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;One documentation manager to integrate the new documentation into the existing body of text, update tables of contents, indexes, etc. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Twenty-five translators to translate the documentation and error messages into all the languages supported by Windows.The managers for the translators live in Ireland (European languages) and Japan (Asian languages), which are both severely time-shifted from Redmond, so dealing with them can be a fairly complex logistical problem. &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;A team of senior managers to coordinate all these people, write the cheques, and justify the costs to their Vice President.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition to the excellent reasons that Eric lists (and the one that often gets forgotten) is compatibility. Despite what appears to be &lt;a href="http://www.hanselman.com/blog/UpdateOnNETFramework35SP1AndWindowsUpdate.aspx"&gt;evidence to the contrary&lt;/a&gt;, the compatibility bar between versions of the Framework is extremely high. Every single public member and type and its behavior needs be maintained indefinitely. The more APIs that are public and/or virtual, the more baggage that needs to be brought forward into future Framework versions so as to not break compatibility.&lt;/p&gt;
&lt;p&gt;Developing good APIs is extremely difficult, especially the first time around. When we get things wrong (and we do get things wrong), trying to maintain backwards compatibility often stifles innovation as we try to correct these scenarios. Unfortunately, unlike others, we don&amp;#39;t have the luxury to make &lt;a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/08/20/smartinstance-in-structuremap-2-5.aspx"&gt;only 95% of our new versions backwards compatible&lt;/a&gt; with our previous versions.&lt;/p&gt;
&lt;p&gt;It is for these very reasons, we try to make our extension points deliberate and designed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://davesbox.com/aggbug.aspx?PostID=1027" width="1" height="1"&gt;</description><category domain="http://davesbox.com/archive/tags/BCL/default.aspx">BCL</category><category domain="http://davesbox.com/archive/tags/API+Design/default.aspx">API Design</category><category domain="http://davesbox.com/archive/tags/Compatibility/default.aspx">Compatibility</category></item><item><title>BUG: Multi-targeting rule not firing on usages of 2.0 SP2 and 3.0 SP2</title><link>http://davesbox.com/archive/2008/11/29/bug-multi-targeting-rule-not-firing-on-usages-of-2-0-sp2-and-3-0-sp2.aspx</link><pubDate>Sat, 29 Nov 2008 15:00:09 GMT</pubDate><guid isPermaLink="false">2122c344-89bc-4cd7-b145-b0515ba3439f:993</guid><dc:creator>David Kean</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/rsscomments.aspx?PostID=993</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/commentapi.aspx?PostID=993</wfw:comment><comments>http://davesbox.com/archive/2008/11/29/bug-multi-targeting-rule-not-firing-on-usages-of-2-0-sp2-and-3-0-sp2.aspx#comments</comments><description>&lt;p&gt;Previously, I&amp;#39;ve spoken about the &lt;a href="http://davesbox.com/archive/2008/08/25/new-for-visual-studio-2008-sp1-and-fxcop-1-36-multi-targeting-rule.aspx"&gt;new multi-targeting rule&lt;/a&gt; that shipped in Visual Studio 2008 SP1 and FxCop 1.36. This rule helps to prevent users from inadvertently taking a dependency on a .NET service pack. Unfortunately, it shipped with a bug that when targeting .NET 3.5, prevented it from firing on usages of types and members only available in .NET 2.0 SP2 and .NET 3.0 SP2 (both installed by 3.5 SP1).&lt;/p&gt; &lt;p&gt;Luckily, the fix is rather simple.&lt;/p&gt; &lt;h5&gt;&lt;strong&gt;In Visual Studio 2008 SP1:&lt;/strong&gt;&lt;/h5&gt; &lt;ol&gt; &lt;li&gt;From an elevated (right-click and Run as administrator) Visual Studio command-prompt, type the following and press &lt;strong&gt;&amp;lt;ENTER&amp;gt;&lt;/strong&gt;:&lt;br /&gt;&lt;br /&gt;devenv &amp;quot;&lt;em&gt;%PROGRAMFILES%\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\Repository\Compatibility\Desktop2.0SP2.xml&amp;quot;&lt;br /&gt;&lt;/em&gt; &lt;li&gt;In the &lt;strong&gt;&amp;lt;CompatibilityEntry&amp;gt;&lt;/strong&gt; element in the file that opens, change the &lt;strong&gt;Priority&lt;/strong&gt; attribute from &lt;em&gt;3&lt;strong&gt;0&lt;/strong&gt;15&lt;/em&gt; to &lt;em&gt;3&lt;strong&gt;5&lt;/strong&gt;15:&lt;/em&gt; &lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;CompatibilityEntry &lt;/span&gt;&lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;.NET Framework 2.0 Service Pack 2&lt;/span&gt;&amp;quot;
                    &lt;span style="color:red;"&gt;Platform&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Desktop&lt;/span&gt;&amp;quot; 
                    &lt;span style="color:red;"&gt;Version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;2.0.2&lt;/span&gt;&amp;quot; 
                    &lt;strong&gt;&lt;em&gt;&lt;span style="color:red;"&gt;Priority&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;3515&lt;/span&gt;&amp;quot;&lt;/em&gt;&lt;/strong&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;li&gt;Save the file. 
&lt;li&gt;From the previously opened command-prompt, type the following and press &lt;strong&gt;&amp;lt;ENTER&amp;gt;&lt;/strong&gt;:&lt;br /&gt;devenv &amp;quot;&lt;em&gt;%PROGRAMFILES%\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\Repository\Compatibility\Desktop3.0SP2.xml&amp;quot;&lt;br /&gt;&lt;br /&gt;&lt;/em&gt;
&lt;li&gt;Similar to above, in the &lt;strong&gt;&amp;lt;CompatibilityEntry&amp;gt;&lt;/strong&gt; element, change the &lt;strong&gt;Priority&lt;/strong&gt; attribute from &lt;em&gt;3&lt;strong&gt;0&lt;/strong&gt;&lt;/em&gt;20 to &lt;em&gt;3&lt;strong&gt;5&lt;/strong&gt;20:&lt;/em&gt; &lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;CompatibilityEntry &lt;/span&gt;&lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;.NET Framework 3.0 Service Pack 2&lt;/span&gt;&amp;quot;
                    &lt;span style="color:red;"&gt;Platform&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Desktop&lt;/span&gt;&amp;quot; 
                    &lt;span style="color:red;"&gt;Version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;3.0.2&lt;/span&gt;&amp;quot; 
                    &lt;span style="color:red;"&gt;Priority&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;3520&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;li&gt;Save the file. &lt;/li&gt;&lt;/ol&gt;
&lt;h5&gt;&lt;strong&gt;In FxCop 1.36:&lt;/strong&gt;&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;Follow the above steps, changing the paths above from &lt;em&gt;&lt;strong&gt;%PROGRAMFILES%\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\Repository\Compatibility&lt;/strong&gt;&lt;/em&gt; to &lt;strong&gt;&lt;em&gt;%PROGRAMFILES%\Microsoft FxCop 1.36\Repository\Compatibility.&lt;/em&gt;&lt;/strong&gt; &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;strong&gt;To verify the fix:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In Visual Studio, start a new C# WPF Application, and paste the following code in the code-behind of App.xaml: &lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;public partial class &lt;/span&gt;&lt;span style="color:#2b91af;"&gt;App &lt;/span&gt;: &lt;span style="color:#2b91af;"&gt;Application
&lt;/span&gt;{
    System.ComponentModel.&lt;span style="color:#2b91af;"&gt;DateTimeOffsetConverter &lt;/span&gt;field1;
    System.Windows.Data.&lt;span style="color:#2b91af;"&gt;BindingGroup &lt;/span&gt;field2;
}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;li&gt;In &lt;strong&gt;Solution Explorer&lt;/strong&gt;, right-click on the project and choose &lt;strong&gt;Run Code Analysis&lt;/strong&gt;. 
&lt;li&gt;If the above steps were followed correctly, you should see warnings similar to the following:&lt;br /&gt;&lt;br /&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="321" alt="UseOnlyApiFromTargetedFramework" src="http://davesbox.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blog/UseOnlyApiFromTargetedFramework_5F00_3.jpg" width="748" border="0" /&gt;&amp;nbsp; &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;This will be fixed in a future release of Visual Studio.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;/em&gt;&lt;/strong&gt;Thanks to &lt;a title="Andrew Smith" href="http://agsmith.wordpress.com/"&gt;Andrew Smith&lt;/a&gt; for bringing this my attention.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://davesbox.com/aggbug.aspx?PostID=993" width="1" height="1"&gt;</description><category domain="http://davesbox.com/archive/tags/FxCop/default.aspx">FxCop</category><category domain="http://davesbox.com/archive/tags/Bugs/default.aspx">Bugs</category><category domain="http://davesbox.com/archive/tags/Compatibility/default.aspx">Compatibility</category></item><item><title>Breaking changes to the String class</title><link>http://davesbox.com/archive/2008/11/12/breaking-changes-to-the-string-class.aspx</link><pubDate>Wed, 12 Nov 2008 15:00:43 GMT</pubDate><guid isPermaLink="false">2122c344-89bc-4cd7-b145-b0515ba3439f:971</guid><dc:creator>David Kean</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/rsscomments.aspx?PostID=971</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/commentapi.aspx?PostID=971</wfw:comment><comments>http://davesbox.com/archive/2008/11/12/breaking-changes-to-the-string-class.aspx#comments</comments><description>&lt;p&gt;You may have already read Justin Van Patten&amp;#39;s post about the &lt;a href="http://blogs.msdn.com/bclteam/archive/2008/11/04/what-s-new-in-the-bcl-in-net-4-0-justin-van-patten.aspx"&gt;upcoming breaking changes to the String class for .NET 4.0&lt;/a&gt;. This change will affect the behavior of the &lt;strong&gt;String.StartsWith&lt;/strong&gt;, &lt;strong&gt;String.&lt;/strong&gt;&lt;strong&gt;EndsWith&lt;/strong&gt;, &lt;strong&gt;String.&lt;/strong&gt;&lt;strong&gt;IndexOf&lt;/strong&gt; and &lt;strong&gt;String.&lt;/strong&gt;&lt;strong&gt;LastIndexOf&lt;/strong&gt; methods by changing them to perform an ordinal (byte-for-byte) comparison by default instead of a culture-sensitive comparison using &lt;strong&gt;CultureInfo.CurrentCulture. &lt;/strong&gt;In addition, the default overloads of &lt;strong&gt;String.ToUpper,&lt;/strong&gt; &lt;strong&gt;String.ToLower&lt;/strong&gt;,&lt;strong&gt; Char.ToUpper &lt;/strong&gt;and &lt;strong&gt;Char.ToLower&lt;/strong&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;will be changed to use &lt;strong&gt;CultureInfo.InvariantCulture&lt;/strong&gt; instead of &lt;strong&gt;CultureInfo.CurrentCulture&lt;/strong&gt;.&lt;/p&gt; &lt;h4&gt;&lt;strong&gt;How does this change affect me? &lt;/strong&gt;&lt;/h4&gt; &lt;p&gt;If you are using an overload of one of the above methods that does not take a &lt;strong&gt;StringComparison&lt;/strong&gt; or &lt;strong&gt;CultureInfo&lt;/strong&gt; as a parameter, then your application or library will be affected when you move it to .NET 4.0. &lt;strong&gt;String.Compare&lt;/strong&gt; and &lt;strong&gt;String.CompareTo&lt;/strong&gt; are not being changed.&lt;/p&gt; &lt;p&gt;An example of the kind of behavior change you could expect, is the following:&lt;/p&gt; &lt;blockquote&gt;&lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;static void &lt;/span&gt;Main()
{
    &lt;span style="color:blue;"&gt;int &lt;/span&gt;index = &lt;span style="color:#a31515;"&gt;&amp;quot;encyclopædia&amp;quot;&lt;/span&gt;.IndexOf(&lt;span style="color:#a31515;"&gt;&amp;quot;encyclopaedia&amp;quot;&lt;/span&gt;);

    &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(index);
}&lt;/pre&gt;&lt;/blockquote&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;On versions previous to .NET 4.0, this will output &lt;em&gt;0&lt;/em&gt; when the user&amp;#39;s current locale is set to some cultures, such &lt;em&gt;en-AU, English (Australia)&lt;/em&gt;, and &lt;em&gt;-1&lt;/em&gt; when the user&amp;#39;s current locale is other cultures, such &lt;em&gt;nn-NO, Norwegian, Nynorsk (Norway)&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;However in .NET 4.0, the above comparison will always output &lt;em&gt;-1&lt;/em&gt;, regardless of the user&amp;#39;s current locale.&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Why was this change made?&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;The comparison methods on the String class have always been a little schizophrenic; some methods, &lt;strong&gt;==&lt;/strong&gt;, &lt;strong&gt;String.Equals&lt;/strong&gt; and &lt;strong&gt;String.Contains &lt;/strong&gt;for example, perform an ordinal comparison by default, whereas the above methods, as well &lt;strong&gt;String.Compare&lt;/strong&gt; and &lt;strong&gt;String&lt;/strong&gt;.&lt;strong&gt;CompareTo,&lt;/strong&gt; perform a culture-sensitive comparison. Because they use the current culture, the default culture-sensitive comparisons can also vary between systems, users and even during the same application session. Which, as pointed out in Justin&amp;#39;s post, can lead to security vulnerabilities in applications that make security decisions using the default overloads. The planned breaking changes bring the majority of these methods inline with each other to have the same default behavior.&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;How do I find and fix these comparisons?&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;To start, you should run &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9aeaa970-f281-4fb0-aba1-d59d7ed09772&amp;amp;DisplayLang=en"&gt;FxCop&lt;/a&gt; or &lt;a href="http://msdn.microsoft.com/en-us/library/3z0aeatx.aspx"&gt;Visual Studio Code Analysis&lt;/a&gt; over your code base. The rules &lt;a href="http://msdn.microsoft.com/en-us/library/bb386080.aspx"&gt;Specify StringComparison&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/ms182189.aspx"&gt;Specify CultureInfo&lt;/a&gt; will fire on call sites that do not explicitly specify a &lt;strong&gt;StringComparison&lt;/strong&gt; or &lt;strong&gt;CultureInfo&lt;/strong&gt;. &lt;a href="http://msdn.microsoft.com/en-us/library/bb385972.aspx"&gt;Specify ordinal StringComparison&lt;/a&gt; will fire when you use invariant culture instead of ordinal to compare, which is almost always wrong.&lt;/p&gt;
&lt;p&gt;To help determine the correct &lt;strong&gt;StringComparison&lt;/strong&gt; or &lt;strong&gt;CultureInfo&lt;/strong&gt; to use, you cannot go past the excellent article &lt;a href="http://msdn.microsoft.com/en-us/library/ms973919.aspx"&gt;New Recommendations for Using Strings in .NET 2.0&lt;/a&gt;. In particular, the section under &lt;strong&gt;Choosing a StringComparison Member for Your Method Call &lt;/strong&gt;provides a table detailing common operations and comparisons to use.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://davesbox.com/aggbug.aspx?PostID=971" width="1" height="1"&gt;</description><category domain="http://davesbox.com/archive/tags/FxCop/default.aspx">FxCop</category><category domain="http://davesbox.com/archive/tags/BCL/default.aspx">BCL</category><category domain="http://davesbox.com/archive/tags/.NET+4.0/default.aspx">.NET 4.0</category><category domain="http://davesbox.com/archive/tags/Compatibility/default.aspx">Compatibility</category></item><item><title>New for Visual Studio 2008 SP1 and FxCop 1.36 – Multi-targeting rule</title><link>http://davesbox.com/archive/2008/08/25/new-for-visual-studio-2008-sp1-and-fxcop-1-36-multi-targeting-rule.aspx</link><pubDate>Mon, 25 Aug 2008 14:00:00 GMT</pubDate><guid isPermaLink="false">2122c344-89bc-4cd7-b145-b0515ba3439f:830</guid><dc:creator>David Kean</dc:creator><slash:comments>21</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/rsscomments.aspx?PostID=830</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/commentapi.aspx?PostID=830</wfw:comment><comments>http://davesbox.com/archive/2008/08/25/new-for-visual-studio-2008-sp1-and-fxcop-1-36-multi-targeting-rule.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Note there is currently a bug in this rule that prevents it from firing on .NET 2.0 SP2 and .NET 3.0 SP2 added APIs when targeting .NET 3.5. See &lt;a href="http://davesbox.com/archive/2008/11/29/bug-multi-targeting-rule-not-firing-on-usages-of-2-0-sp2-and-3-0-sp2.aspx" class="null"&gt;BUG: Multi-targeting rule not firing on usages of 2.0 SP2 and 3.0 SP2&lt;/a&gt; for more information.&lt;/p&gt;
&lt;p&gt;Back in October of last year, Krzysztof Cwalina &lt;a href="http://blogs.msdn.com/kcwalina/archive/2007/10/02/Multi_2D00_TargetingAndFxCop.aspx"&gt;talked about the multi-targeting changes&lt;/a&gt; in Visual Studio 2008 and .NET 3.5. He mentioned the limitations in its design that could cause an application that explicitly targets .NET Framework 2.0 and .NET Framework 3.0 to accidently take a dependency on a new member or type that did not exist in the &lt;a href="http://en.wikipedia.org/wiki/Software_release_life_cycle#RTM_or_RTW"&gt;RTM version&lt;/a&gt; of that framework. As a workaround, he posted the source code of a Code Analysis/FxCop rule that could detect and fire on a member that took one of these dependencies. &lt;/p&gt;
&lt;p&gt;A little while before he wrote that post, my team at the time, the Code Analysis team, was approached to see if we could ship a similar rule out of the box. Unfortunately, we ran out of time to get it included in Visual Studio 2008 RTM and FxCop Beta 2, however, I&amp;rsquo;m pleased to announce that we&amp;rsquo;ve added the rule, &lt;i&gt;Use only API from targeted framework&lt;/i&gt;, to &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;amp;displaylang=en"&gt;Visual Studio 2008 SP1&lt;/a&gt; and &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9aeaa970-f281-4fb0-aba1-d59d7ed09772&amp;amp;DisplayLang=en"&gt;FxCop 1.36 RTM&lt;/a&gt; release. &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; The Visual Studio integration for this rule is only available in editions that support Code Analysis; &lt;i&gt;Visual Studio Team Development Edition&lt;/i&gt; and &lt;i&gt;Visual Studio Team Suite&lt;/i&gt;. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;How this rule works&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;In Visual Studio, this rule reads the current targeted framework stored in the C# or Visual Basic project and fires on any usage of API that was not included in the RTM version of that framework. Whereas, in FxCop, the rule reads the targeted framework stored within the FxCop project or passed via the command-line. &lt;/p&gt;
&lt;p&gt;The following table attempts to explain this:&lt;/p&gt;
&lt;table cellpadding="0" cellspacing="0" style="border-right:medium none;border-top:medium none;border-left:medium none;width:6.7in;border-bottom:medium none;border-collapse:collapse;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0in 5.4pt 0in 5.4pt;" class="MsoTableGrid"&gt;

&lt;tr&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:2.2in;padding-top:0in;border-bottom:windowtext 1.5pt solid;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;td colspan="3" style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:windowtext 1.5pt solid;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:4.5in;padding-top:0in;border-bottom:windowtext 1.5pt solid;mso-border-left-alt:solid windowtext 1.5pt;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;When Target Framework (in Project properties or in FxCop project options/command-line) is set to:&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:1;"&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:windowtext 1.5pt solid;width:2.2in;padding-top:0in;border-bottom:windowtext 1.5pt solid;mso-border-top-alt:solid windowtext 1.5pt;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;Code Analysis/FxCop fires on usage of:&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:103.5pt;padding-top:0in;border-bottom:windowtext 1.5pt solid;mso-border-alt:solid windowtext 1.5pt;mso-border-left-alt:solid windowtext 1.5pt;mso-border-top-alt:solid windowtext 1.5pt;mso-border-right-themecolor:text1;mso-border-right-alt:solid black .5pt;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;.NET Framework 2.0&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:1.5in;padding-top:0in;border-bottom:windowtext 1.5pt solid;mso-border-left-alt:black .5pt;mso-border-top-alt:windowtext 1.5pt;mso-border-right-themecolor:text1;mso-border-right-alt:black .5pt;mso-border-left-themecolor:text1;mso-border-bottom-alt:windowtext 1.5pt;mso-border-style-alt:solid;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;.NET Framework 3.0&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:112.5pt;padding-top:0in;border-bottom:windowtext 1.5pt solid;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid windowtext 1.5pt;mso-border-left-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;.NET Framework&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;3.5&lt;sup&gt;&amp;Dagger;&lt;/sup&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:2;"&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:windowtext 1.5pt solid;width:2.2in;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid windowtext 1.5pt;mso-border-top-alt:solid windowtext 1.5pt;mso-border-bottom-alt:solid black .5pt;mso-border-bottom-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;.NET Framework 2.0&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:103.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-left-alt:windowtext 1.5pt;mso-border-top-alt:windowtext 1.5pt;mso-border-right-themecolor:text1;mso-border-right-alt:black .5pt;mso-border-bottom-alt:black .5pt;mso-border-style-alt:solid;mso-border-bottom-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:1.5in;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid windowtext 1.5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:112.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-left-alt:black .5pt;mso-border-top-alt:windowtext 1.5pt;mso-border-right-alt:windowtext 1.5pt;mso-border-left-themecolor:text1;mso-border-bottom-alt:black .5pt;mso-border-style-alt:solid;mso-border-bottom-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:3;"&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:windowtext 1.5pt solid;width:2.2in;padding-top:0in;border-bottom:black 1pt solid;mso-border-left-alt:windowtext 1.5pt;mso-border-top-alt:black .5pt;mso-border-right-alt:windowtext 1.5pt;mso-border-bottom-alt:black .5pt;mso-border-style-alt:solid;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;.NET Framework 2.0 SP1&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:103.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid windowtext 1.5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:1.5in;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:112.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-alt:solid windowtext 1.5pt;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:4;"&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:windowtext 1.5pt solid;width:2.2in;padding-top:0in;border-bottom:black 1pt solid;mso-border-left-alt:windowtext 1.5pt;mso-border-top-alt:black .5pt;mso-border-right-alt:windowtext 1.5pt;mso-border-bottom-alt:black .5pt;mso-border-style-alt:solid;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;.NET Framework 2.0 SP2&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:103.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid windowtext 1.5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:1.5in;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:112.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-alt:solid windowtext 1.5pt;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:5;"&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:windowtext 1.5pt solid;width:2.2in;padding-top:0in;border-bottom:black 1pt solid;mso-border-left-alt:windowtext 1.5pt;mso-border-top-alt:black .5pt;mso-border-right-alt:windowtext 1.5pt;mso-border-bottom-alt:black .5pt;mso-border-style-alt:solid;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;.NET Framework 3.0&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:103.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid windowtext 1.5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;sup&gt;&amp;dagger;&lt;/sup&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:1.5in;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:112.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-alt:solid windowtext 1.5pt;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:6;"&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:windowtext 1.5pt solid;width:2.2in;padding-top:0in;border-bottom:black 1pt solid;mso-border-left-alt:windowtext 1.5pt;mso-border-top-alt:black .5pt;mso-border-right-alt:windowtext 1.5pt;mso-border-bottom-alt:black .5pt;mso-border-style-alt:solid;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;.NET Framework 3.0 SP1&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:103.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid windowtext 1.5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;sup&gt;&amp;dagger;&lt;/sup&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:1.5in;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:112.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-alt:solid windowtext 1.5pt;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:7;"&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:windowtext 1.5pt solid;width:2.2in;padding-top:0in;border-bottom:black 1pt solid;mso-border-left-alt:windowtext 1.5pt;mso-border-top-alt:black .5pt;mso-border-right-alt:windowtext 1.5pt;mso-border-bottom-alt:black .5pt;mso-border-style-alt:solid;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;.NET Framework 3.0 SP2&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:103.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid windowtext 1.5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;sup&gt;&amp;dagger;&lt;/sup&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:1.5in;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:112.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-alt:solid windowtext 1.5pt;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:8;"&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:windowtext 1.5pt solid;width:2.2in;padding-top:0in;border-bottom:black 1pt solid;mso-border-left-alt:windowtext 1.5pt;mso-border-top-alt:black .5pt;mso-border-right-alt:windowtext 1.5pt;mso-border-bottom-alt:black .5pt;mso-border-style-alt:solid;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;.NET Framework 3.5&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:103.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid windowtext 1.5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;sup&gt;&amp;dagger;&lt;/sup&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:1.5in;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;sup&gt;&amp;dagger;&lt;/sup&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:112.5pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-alt:solid windowtext 1.5pt;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:9;mso-yfti-lastrow:yes;"&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:windowtext 1.5pt solid;width:2.2in;padding-top:0in;border-bottom:windowtext 1.5pt solid;mso-border-top-alt:solid black .5pt;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;.NET Framework 3.5 SP1&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:103.5pt;padding-top:0in;border-bottom:windowtext 1.5pt solid;mso-border-left-alt:windowtext 1.5pt;mso-border-top-alt:black .5pt;mso-border-right-themecolor:text1;mso-border-right-alt:black .5pt;mso-border-bottom-alt:windowtext 1.5pt;mso-border-style-alt:solid;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;sup&gt;&amp;dagger;&lt;/sup&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:1.5in;padding-top:0in;border-bottom:windowtext 1.5pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-alt:solid windowtext 1.5pt;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;sup&gt;&amp;dagger;&lt;/sup&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:windowtext 1.5pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:112.5pt;padding-top:0in;border-bottom:windowtext 1.5pt solid;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-left-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p align="center" style="margin-bottom:0pt;line-height:normal;text-align:center;"&gt;&amp;bull;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;/table&gt;
&lt;p class="MsoNormal"&gt;&lt;sup&gt;&amp;dagger;&lt;/sup&gt; &lt;span style="font-size:9pt;line-height:115%;"&gt;MSBuild prevents a user from mixing these combinations in Visual Studio, so only FxCop can fire on this.&lt;br /&gt;&lt;/span&gt;&lt;sup&gt;&amp;Dagger; &lt;/sup&gt;&lt;span style="font-size:9pt;line-height:115%;"&gt;Client-only Framework subset is not supported.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For example, when a user selects &lt;i&gt;.NET Framework 3.0&lt;/i&gt; as their project&amp;rsquo;s target framework, Code Analysis and FxCop will fire on any usage of members and types that were introduced in &lt;i&gt;.NET Framework 2.0 SP1 and SP2&lt;/i&gt;, .&lt;i&gt;NET Framework 3.0 SP1 &lt;/i&gt;and&lt;i&gt; SP2&lt;/i&gt;, &lt;i&gt;.NET Framework 3.5&lt;/i&gt; and &lt;i&gt;.NET Framework 3.5 SP1&lt;/i&gt;. This is because on a fresh install of .NET Framework 3.0 (such as on Vista RTM), none of these service packs or frameworks are installed.&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Enabling in Visual Studio&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;By default, Visual Studio projects with the default Code Analysis settings will already have the rule enabled. To check this, do the following: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In &lt;b&gt;Solution Explorer&lt;/b&gt;, right-click on your project and choose &lt;b&gt;Properties&lt;/b&gt; &lt;/li&gt;
&lt;li&gt;Choose the &lt;b&gt;Code Analysis&lt;/b&gt; tab &lt;/li&gt;
&lt;li&gt;Expand the &lt;b&gt;Portability&lt;/b&gt; node and ensure that &lt;b&gt;Use only API from targeted framework&lt;/b&gt; is checked &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img border="0" width="714" src="http://davesbox.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blog/image20.png" alt="Use only API from targeted framework" height="446" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" /&gt; &lt;/p&gt;
&lt;p&gt;Once this rule has been enabled, you need to make sure that you targeting the framework that you plan to release your application on. To verify this, do the following:&amp;nbsp; &lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;For C# projects:&lt;/strong&gt;&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;In &lt;b&gt;Solution Explorer&lt;/b&gt;, right-click on your project and choose &lt;b&gt;Properties&lt;/b&gt; &lt;/li&gt;
&lt;li&gt;Choose the &lt;b&gt;Application&lt;/b&gt; tab &lt;/li&gt;
&lt;li&gt;From the&lt;b&gt; Targeted Framework&lt;/b&gt; drop down, choose the framework that your application is targeting &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img border="0" width="737" src="http://davesbox.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blog/CSharpTargetFramewor_5F00_3.png" alt="Target Framework in C# project properties" height="549" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" /&gt;&amp;nbsp;&lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;For Visual Basic projects:&lt;/strong&gt;&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;In &lt;b&gt;Solution Explorer&lt;/b&gt;, right-click on your project and choose &lt;b&gt;Properties&lt;/b&gt; &lt;/li&gt;
&lt;li&gt;Choose the &lt;b&gt;Build&lt;/b&gt; tab and click &lt;b&gt;Advanced Compile Options&amp;hellip;&lt;/b&gt; &lt;/li&gt;
&lt;li&gt;From the &lt;b&gt;Target framework (all configurations)&lt;/b&gt; drop down, choose the framework that your application is targeting &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img border="0" width="650" src="http://davesbox.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blog/VisualBasicTargetFramework_5F00_3.png" alt="Target Framework in Visual Basic project properties" height="514" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" /&gt; &lt;/p&gt;
&lt;p&gt;Once you&amp;rsquo;ve done the above, running Code Analysis (&lt;b&gt;Analyze&lt;/b&gt; -&amp;gt; &lt;b&gt;Run Code Analysis&lt;/b&gt;) should now fire on any service pack dependencies your project has taken on. For example, using &lt;i&gt;DateTimeOffset&lt;/i&gt; in a project that is set to target &lt;i&gt;.NET Framework 2.0&lt;/i&gt;, will cause the following warning to output. &lt;/p&gt;
&lt;p&gt;&lt;img border="0" width="781" src="http://davesbox.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blog/ErrorList_5F00_3.png" alt="&amp;#39;Use only API from targeted Framework&amp;#39; warning" height="238" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" /&gt;&amp;nbsp; &lt;/p&gt;
&lt;h4&gt;&lt;strong&gt;Enabling in FxCop&lt;/strong&gt;&lt;/h4&gt;
&lt;p&gt;In contrast to Visual Studio, &lt;i&gt;Use only API from targeted framework&lt;/i&gt; does not fire by default in FxCop. This is because FxCop does not have access to the project (.csproj, .vbproj) of the assembly that it is analyzing, and hence cannot automatically determine the Framework your application is targeting. Because of this, you need explicitly specify it; either via the FxCop project or via the command-line. &lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;Enabling using an FxCop project&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;By default, FxCop projects will already have the rule enabled. To check this, do the following: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open your FxCop project in FxCop &lt;/li&gt;
&lt;li&gt;Choose the &lt;b&gt;Rules&lt;/b&gt; tab &lt;/li&gt;
&lt;li&gt;Expand the &lt;b&gt;Portability&lt;/b&gt; node and ensure that &lt;b&gt;Use only API from targeted framework&lt;/b&gt; is checked &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img border="0" width="746" src="http://davesbox.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blog/image4.png" alt="Use only API from target framewor" height="577" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" /&gt; &lt;/p&gt;
&lt;p&gt;Once this rule has been enabled, it will not fire until you tell FxCop the framework you are targeting. To do this, do the following: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open your FxCop project in FxCop &lt;/li&gt;
&lt;li&gt;Choose &lt;b&gt;Project&lt;/b&gt; -&amp;gt; &lt;b&gt;Options&lt;/b&gt; and then choose the &lt;b&gt;Spelling &amp;amp; Analysis&lt;/b&gt; tab &lt;/li&gt;
&lt;li&gt;From the &lt;b&gt;Target Framework&lt;/b&gt; drop down, choose the framework you are targeting. Typically this would match the value specified in your C#, Visual Basic or C++ project&amp;rsquo;s properties. &lt;/li&gt;
&lt;li&gt;Click &lt;b&gt;OK&lt;/b&gt; &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img border="0" width="558" src="http://davesbox.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blog/TargetFrameworkOption_5F00_3.png" alt="Target Framework in FxCop" height="458" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" /&gt; &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Note: &lt;/b&gt;You can make this the default for all new FxCop projects and for the command-line by clicking &lt;b&gt;Defaults&amp;hellip;&lt;/b&gt; after you open the &lt;b&gt;Project Options&lt;/b&gt; dialog and then following the rest of the steps above. &lt;/p&gt;
&lt;p&gt;Once you&amp;rsquo;ve done the above, running analysis (&lt;b&gt;Project&lt;/b&gt; -&amp;gt; &lt;b&gt;Analyze&lt;/b&gt;) should now fire on any service pack dependencies your application has taken on. For example, using &lt;i&gt;DateTimeOffset&lt;/i&gt; in a assembly that is set to target &lt;i&gt;.NET Framework 2.0&lt;/i&gt;, will cause the following error to output: &lt;/p&gt;
&lt;p&gt;&lt;img border="0" width="759" src="http://davesbox.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/blog/FxCopAnalysis_5F00_3.png" alt="&amp;#39;Use only API from targeted framework&amp;#39; error" height="589" style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" /&gt;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;Enabling via the command-line&lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;While the preferred method to specify the target framework is by using an FxCop project as described above, you can also specify it explicitly via the command-line. The new /targetframeworkversion switch was added for this purpose. Its valid values are described below: &lt;/p&gt;
&lt;table cellpadding="0" cellspacing="0" style="border-right:medium none;border-top:medium none;border-left:medium none;border-bottom:medium none;border-collapse:collapse;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-yfti-tbllook:1184;mso-padding-alt:0in 5.4pt 0in 5.4pt;" class="MsoTableGrid"&gt;

&lt;tr&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:black 1pt solid;padding-left:5.4pt;padding-bottom:0in;border-left:black 1pt solid;width:239.4pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;Argument&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:black 1pt solid;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:239.4pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-left-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;&lt;b style="mso-bidi-font-weight:normal;"&gt;Description&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:1;"&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:black 1pt solid;width:239.4pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-top-alt:solid black .5pt;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;/targetframeworkversion:2.0&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:239.4pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;Specifies .NET Framework 2.0&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:2;"&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:black 1pt solid;width:239.4pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-top-alt:solid black .5pt;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;/targetframeworkversion:3.0&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:239.4pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;Specifies .NET Framework 3.0&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:3;"&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:black 1pt solid;width:239.4pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-top-alt:solid black .5pt;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;/targetframeworkversion:3.5&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:239.4pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;Specifies .NET Framework 3.5&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="mso-yfti-irow:4;mso-yfti-lastrow:yes;"&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:black 1pt solid;width:239.4pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-top-alt:solid black .5pt;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;/targetframeworkversion:none&lt;/p&gt;
&lt;/td&gt;
&lt;td style="border-right:black 1pt solid;padding-right:5.4pt;border-top:medium none;padding-left:5.4pt;padding-bottom:0in;border-left:medium none;width:239.4pt;padding-top:0in;border-bottom:black 1pt solid;mso-border-alt:solid black .5pt;mso-border-themecolor:text1;mso-border-left-alt:solid black .5pt;mso-border-top-alt:solid black .5pt;mso-border-right-themecolor:text1;mso-border-left-themecolor:text1;mso-border-bottom-themecolor:text1;mso-border-top-themecolor:text1;"&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;Disables the rule.&lt;/p&gt;
&lt;p style="margin-bottom:0pt;line-height:normal;"&gt;This is the default. However, it can useful to specify this argument if you want to override the associated setting stored in an FxCop project that is passed on the same command-line.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;/table&gt;
&lt;p&gt;Specifying any of these arguments on a command-line will override the target framework setting stored in the FxCop project. &lt;/p&gt;
&lt;p&gt;An example command-line would be the following: &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span style="font-family:Courier New;"&gt;FxCopCmd.exe /file:MyAssembly.dll /console /targetframeworkversion:2.0&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h5&gt;&lt;strong&gt;Disabling the rule or targeting specific service packs &lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;&lt;i&gt;Use only API from targeted framework&lt;/i&gt; does not have support for targeting specific service packs, such as .NET Framework 2.0 SP1. If you want to deliberately take a dependency on a service pack, simply disable the rule by unchecking instead of checking the rule in the &lt;b&gt;Enabling in Visual Studio&lt;/b&gt; and &lt;b&gt;Enabling in FxCop&lt;/b&gt; sections.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://davesbox.com/aggbug.aspx?PostID=830" width="1" height="1"&gt;</description><category domain="http://davesbox.com/archive/tags/FxCop/default.aspx">FxCop</category><category domain="http://davesbox.com/archive/tags/Compatibility/default.aspx">Compatibility</category></item></channel></rss>