<?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 : Bugs, FxCop</title><link>http://davesbox.com/archive/tags/Bugs/FxCop/default.aspx</link><description>Tags: Bugs, FxCop</description><dc:language>en</dc:language><generator>CommunityServer 2008 (Build: 30417.1769)</generator><item><title>Make sure you use the tools at your disposal</title><link>http://davesbox.com/archive/2009/02/19/make-sure-you-use-the-tools-at-your-disposal.aspx</link><pubDate>Thu, 19 Feb 2009 15:00:00 GMT</pubDate><guid isPermaLink="false">2122c344-89bc-4cd7-b145-b0515ba3439f:1653</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=1653</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/commentapi.aspx?PostID=1653</wfw:comment><comments>http://davesbox.com/archive/2009/02/19/make-sure-you-use-the-tools-at-your-disposal.aspx#comments</comments><description>&lt;p&gt;I ran across something interesting on an internal alias about a new marketing campaign on the &lt;a href="http://www.microsoft.com/visualstudio/en-us/products/teamsystem/default.mspx"&gt;Visual Studio Team System marketing site&lt;/a&gt; that allows you to customize an amusing video that you can send to friends and team members. What caught my eye wasn’t the video itself, but the error that some users were encountering when attempting to view one of the Silverlight-based videos:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Message: Unhandled Error in Silverlight 2 Application [Format_InvalidString]      &lt;br /&gt;Arguments:&lt;/p&gt;    &lt;p&gt;Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See &lt;a href="http://go.microsoft.com/fwlink/?linkid=106663&amp;amp;Version=2.0.31005.0&amp;amp;File=mscorlib.dll&amp;amp;Key=Format_InvalidString"&gt;http://go.microsoft.com/fwlink/?linkid=106663&amp;amp;Version=2.0.31005.0&amp;amp;File=mscorlib.dll&amp;amp;Key=Format_InvalidString&lt;/a&gt;&amp;#160;&amp;#160; at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp;amp; number, NumberFormatInfo info, Boolean parseDecimal)       &lt;br /&gt;&amp;#160;&amp;#160; at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)       &lt;br /&gt;&amp;#160;&amp;#160; at System.Double.Parse(String s, NumberStyles style, NumberFormatInfo info)       &lt;br /&gt;&amp;#160;&amp;#160; at System.Double.Parse(String s, IFormatProvider provider)       &lt;br /&gt;&amp;#160;&amp;#160; at System.Convert.ToDouble(String value)       &lt;br /&gt;&amp;#160;&amp;#160; at PepTalk_Full.DataObjects.doTextOverlay..ctor(XElement element)       &lt;br /&gt;&amp;#160;&amp;#160; at PepTalk_Full.DataObjects.doPepTalk.Init()       &lt;br /&gt;&amp;#160;&amp;#160; at PepTalk_Full.DataObjects.doPepTalk..ctor()       &lt;br /&gt;&amp;#160;&amp;#160; at PepTalk_Full.App.wc_DownloadStringCompleted(Object sender, DownloadStringCompletedEventArgs e)       &lt;br /&gt;&amp;#160;&amp;#160; at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e)       &lt;br /&gt;&amp;#160;&amp;#160; at System.Net.WebClient.DownloadStringOperationCompleted(Object arg)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;To keep download sizes smaller, the client Silverlight plug-in does not contain Exception error messages, but by clicking the URL above, or by looking at the stack can you guess what the problem is? I’ll give you a hint – Convert.ToDouble(String) passes &lt;a href="http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.currentculture.aspx"&gt;CultureInfo.CurrentCulture&lt;/a&gt; as the IFormatProvider argument to Double.Parse.&lt;/p&gt;  &lt;p&gt;Yep, you guessed it, basically, the application is attempting to parse a string that it has downloaded from the web and the call to Convert.ToDouble is failing because it is expecting the format of the string to match the current culture, while the string itself is formatted using another culture. For example, the string likely contains a value formatted using the invariant culture, say &lt;em&gt;‘1.00’&lt;/em&gt;, but when a visitor from Germany or Norway comes to visit, Convert.ToDouble(String) is looking for a string in the format ‘&lt;em&gt;1&lt;strong&gt;,&lt;/strong&gt;00’&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;The irony in all this is that if the Microsoft team or contractor that wrote the Silverlight application were actually using the Code Analysis feature of Team System, they would have received the following warning from &lt;a href="http://msdn.microsoft.com/en-us/library/ms182190.aspx"&gt;Specify IFormatProvider&lt;/a&gt;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;i&gt;Because the behavior of &amp;#39;Convert.ToDouble(string)&amp;#39; could vary based on the current user&amp;#39;s locale settings, replace this call in &amp;#39;doTextOverlay.doTextOverlay(XElement)&amp;#39; with a call to &amp;#39;Convert.ToDouble(string, IFormatProvider)&amp;#39;. If the result of &amp;#39;Convert.ToDouble(string, IFormatProvider)&amp;#39; will be displayed to the user, specify &amp;#39;CultureInfo.CurrentCulture&amp;#39; as the &amp;#39;IFormatProvider&amp;#39; parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify &amp;#39;CultureInfo.InvariantCulture&amp;#39;.&lt;/i&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;All the developer has to do is to call the overload of Convert.ToDouble that takes an IFormatProvider passing it CultureInfo.InvariantCulture and the application would work on all systems regardless of the user’s culture.&lt;/p&gt;  &lt;p&gt;The moral of the story is, use the tools available at your disposal – if you have Team System, use Code Analysis, otherwise, we still offer &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=9AEAA970-F281-4FB0-ABA1-D59D7ED09772"&gt;FxCop&lt;/a&gt; as a free download – they both catch bugs like this one.     &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://davesbox.com/aggbug.aspx?PostID=1653" 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></item><item><title>Code Analysis failing with ‘Invalid settings passed to CodeAnalysis task’</title><link>http://davesbox.com/archive/2008/12/26/code-analysis-failing-with-invalid-settings-passed-to-codeanalysis-task.aspx</link><pubDate>Fri, 26 Dec 2008 15:00:00 GMT</pubDate><guid isPermaLink="false">2122c344-89bc-4cd7-b145-b0515ba3439f:1097</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=1097</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/commentapi.aspx?PostID=1097</wfw:comment><comments>http://davesbox.com/archive/2008/12/26/code-analysis-failing-with-invalid-settings-passed-to-codeanalysis-task.aspx#comments</comments><description>&lt;p&gt;I’ve seen recent reports of Visual Studio Code Analysis failing (such as &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/3a626e7a-c144-4f39-9dc7-54cb129fae04/"&gt;this one&lt;/a&gt;) with the following error:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Invalid settings passed to CodeAnalysis task.&amp;#160; See output window for details.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Looking in the output window will show something similar to:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Switch &amp;#39;/targetframeworkversion&amp;#39; is an unknown switch.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;As &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;I’ve mentioned earlier&lt;/a&gt;, the &lt;em&gt;/targetframeworkversion&lt;/em&gt; switch was added in Visual Studio 2008 SP1 to support the new multi-targeting rule. The fact that the FxCop does not understand the switch, is a big indicator that something went astray with the installation of the service pack.&lt;/p&gt;  &lt;p&gt;Luckily the fix is rather easy, simple &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;amp;displaylang=en"&gt;re-install it&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://davesbox.com/aggbug.aspx?PostID=1097" 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></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>Reference resolution changes in Code Analysis and FxCop – Part 2</title><link>http://davesbox.com/archive/2008/06/14/reference-resolutions-changes-in-code-analysis-and-fxcop-part-2.aspx</link><pubDate>Sat, 14 Jun 2008 14:00:00 GMT</pubDate><guid isPermaLink="false">2122c344-89bc-4cd7-b145-b0515ba3439f:29</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=29</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://davesbox.com/commentapi.aspx?PostID=29</wfw:comment><comments>http://davesbox.com/archive/2008/06/14/reference-resolutions-changes-in-code-analysis-and-fxcop-part-2.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://davesbox.com/archive/2008/06/10/reference-resolution-changes-in-code-analysis-and-fxcop-part-1.aspx"&gt;Previously&lt;/a&gt;, I mentioned the reference resolution changes that were made in Code Analysis for 2008 and FxCop 1.36. Unfortunately, not long after we shipped Visual Studio 2008, &lt;a href="http://davidgardiner.blogspot.com/2007/11/code-analysis-vslangproj-and-envdte.html"&gt;we found an uncommon scenario&lt;/a&gt; in which the strong name matching prevented Code Analysis/FxCop from analyzing a binary even though all assemblies used for compilation were present. &lt;/p&gt;
&lt;p&gt;The scenario occurs when you have something similar to the following:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://davesbox.com/images/blog/references.gif" alt="" /&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you can see above, &lt;em&gt;Assembly 1.0.0.0&lt;/em&gt; has a reference to &lt;em&gt;VSLangProj&lt;/em&gt; &lt;em&gt;8.0.0.0 &lt;/em&gt;and &lt;em&gt;EnvDTE 8.0.0.0&lt;/em&gt;. Whereas, &lt;em&gt;VSLangProj 8.0.0.0&lt;/em&gt; has a reference to &lt;em&gt;EnvDTE 7.0.3300.0&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;Surprisingly, the C# compiler actually allows you to compile the above assembly against VSLangProj with a later version of EnvDTE. It allows this, by substituting the 7.0.3300.0 version of the EnvDTE types exposed by VSLangProj, with their 8.0.0.0 equivalent. However, when doing this, it stills adds a reference in the assembly manifest to both versions of EnvDTE; 7.0.3300.0 and 8.0.0.0, even though you never explicitly added a reference to the former.&lt;/p&gt;
&lt;p&gt;In contrast to the compiler, both Code Analysis and the CLR itself by default do not consider types from a later version of an assembly to be the same as their equivalent from an earlier version. In other words, the compiler behavior and the runtime behavior are in direct conflict of each other. In fact, the only way to get such an assembly to load in the CLR, is to add a &lt;a href="http://msdn.microsoft.com/en-us/library/ms228768.aspx"&gt;binding redirect from EnvDTE 7.0.3300.0 &amp;ndash;&amp;gt; 8.0.0.0&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When you attempt to run Code Analysis/FxCop over an assembly with references similar to above, you might encounter two different errors with the same underlying cause:&lt;/p&gt;
&lt;p&gt;The first error complains about a missing reference:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;error : CA0058 : The referenced assembly &amp;#39;EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&amp;#39; could not be found. This assembly is required for analysis and was referenced by: &amp;#39;Assembly.dll&amp;#39;.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Whereas, the second error complains about failing to load the assembly: &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;error : CA0055 : Could not load Assembly.dll. &lt;br /&gt;error : CA0052 : No targets were selected. &lt;br /&gt;&lt;br /&gt;&lt;/em&gt;Opening the &lt;em&gt;[AssemblyName]CodeAnalysisLog.xml&lt;/em&gt; in output directory will contain something similar to: &lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;lt;Exceptions&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;lt;Exception Keyword=&amp;quot;CA0055&amp;quot; Kind=&amp;quot;AssemblyLoad&amp;quot;&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;Type&amp;gt;Microsoft.FxCop.Common.AssemblyLoadException&amp;lt;/Type&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;ExceptionMessage&amp;gt;Could not load Target.exe.&amp;lt;/ExceptionMessage&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;InnerType&amp;gt;Microsoft.FxCop.Sdk.InvalidMetadataException&amp;lt;/InnerType&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;InnerExceptionMessage&amp;gt;&lt;strong&gt;The following error was encountered while reading module &amp;#39;Assembly&amp;#39;: Could not resolve member reference: VSLangProj.BuildManager::get_ContainingProject.&lt;/strong&gt;&amp;lt;/InnerExceptionMessage&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;InnerStackTrace&amp;gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Sdk.Reader.HandleError(ModuleNode mod, String errorMessage) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Sdk.Reader.GetMemberFromRef(Int32 i, TypeNodeCollection&amp;amp;amp; varArgTypes, Int32 numGenericArgs) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Sdk.Reader.GetMethodDefOrRef(Int32 codedIndex) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Sdk.Reader.GetTypeMembers(TypeNode type, Object handle) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Sdk.TypeNode.get_Members() &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Engines.Introspection.LoadVisitor.VisitType(TypeNode type, TargetType target) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Engines.Introspection.BaseVisitor.VisitTypes(TypeNodeCollection types, TargetNamespaceDictionary targets) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Engines.Introspection.LoadVisitor.VisitModule(ModuleNode module, TargetModule target) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Engines.Introspection.BaseVisitor.VisitAssembly(AssemblyNode assembly, TargetFile target) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Engines.Introspection.LoadVisitor.VisitAssembly(AssemblyNode assembly, TargetFile target) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Engines.Introspection.LoadVisitor.Load(TargetFile target, Boolean buildTree, Boolean queueItems, AssemblyNode loadedAssembly) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Engines.Introspection.IntrospectionAnalysisEngine.LoadTargets(TargetFile target) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.FxCop.Common.EngineManager.LoadTargets(TargetFile target, Boolean resetCounts, String loadEngine)&amp;lt;/InnerStackTrace&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;lt;/Exception&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;lt;Exception Keyword=&amp;quot;CA0052&amp;quot; Kind=&amp;quot;Engine&amp;quot;&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;Type&amp;gt;Microsoft.FxCop.Sdk.FxCopException&amp;lt;/Type&amp;gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;lt;ExceptionMessage&amp;gt;No targets were selected.&amp;lt;/ExceptionMessage&amp;gt; &lt;br /&gt;&amp;nbsp; &amp;lt;/Exception&amp;gt; &lt;br /&gt;&amp;lt;/Exceptions&amp;gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Luckily, there are a couple of workarounds for those that run into this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Add a reference to the earlier version of the assembly (ie above this would be EnvDTE 7.0.3300.0), removing the reference to the later version. &lt;br /&gt;&lt;br /&gt;Unfortunately, if you need features only available in the later version or the earlier version of the assembly is not always available (if you are hitting this with EnvDTE, then this is most likely the case), this option will not work. In those cases, use the next option. &lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Use an &lt;em&gt;unsupported&lt;/em&gt; configuration setting and change Code Analysis/FxCop&amp;rsquo;s resolving logic: &lt;br /&gt;&lt;br /&gt;&lt;ol&gt;
&lt;li&gt;Using a text editor, open the &lt;strong&gt;FxCopCmd.exe.config&lt;/strong&gt; file located in &lt;strong&gt;&lt;em&gt;%PROGRAMFILES%\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop&lt;/em&gt; &lt;/strong&gt;(Code Analysis) or &lt;strong&gt;%PROGRAMFILES%\Microsoft FxCop 1.36&lt;/strong&gt; (FxCop) &lt;/li&gt;
&lt;li&gt;Change the &lt;strong&gt;AssemblyReferenceResolveMode&lt;/strong&gt; from &lt;strong&gt;StrongName&lt;/strong&gt; to &lt;strong&gt;StrongNameIgnoringVersion&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Save the text file &lt;/li&gt;
&lt;li&gt;If using FxCop standalone, repeat the same procedure for &lt;strong&gt;FxCop.exe.config&lt;/strong&gt; &lt;br /&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Once you have changed this setting, Code Analysis/FxCop will start treating the references similar to how the compiler does. Taking above as an example, types in EnvDTE 8.0.0.0 will be considered a match for their 7.0.3300.0 counterparts. &lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In future versions, it is likely that Code Analysis/FxCop will move to a model that closely mimics the C# compiler&amp;rsquo;s /reference switch, which will allow it to dynamically choose the correct resolving mode based on the available references.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://davesbox.com/aggbug.aspx?PostID=29" 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></item></channel></rss>