After upgrading to Service Pack 1, the error 'CA0055: Could not load [AssemblyName]' occurs when running Code Analysis

We've been hearing a few reports of the following errors being output to the Error List after upgrading to Visual Studio 2005 Service Pack 1 (SP1):

CA0055 : Could not load [AssemblyName].
CA0052 : No targets were selected.

If you look at the [AssemblyName].CodeAnalysisLog.xml file within your output folder, it may have contents similar to the following:


xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="c:\program files\microsoft visual studio 8\team tools\static analysis tools\fxcop\Xml\CodeAnalysisReport.Xsl"?>
<FxCopReport Version="8">
<String Key="Category">Category</String>
<String Key="CollapseAll">Collapse All</String>
<String Key="CheckId">Check Id</String>
<String Key="Error">Error</String>
<String Key="Errors">error(s)</String>
<String Key="Line">Line</String>
<String Key="LocationNotStoredInPdb">&lt;Location not stored in Pdb&gt;</String>
<String Key="Project">Project</String>
<String Key="Rule">Rule</String>
<String Key="RuleDescription">Rule Description</String>
<String Key="Source">Source</String>
<String Key="Target">Target</String>
<String Key="Warning">Warning</String>
<String Key="Warnings">warning(s)</String>
<String Key="ReportTitle">Microsoft Visual Studio 2005 Code Analysis Report</String>
<Exception Keyword="CA0055" Kind="AssemblyLoad">
<ExceptionMessage>Could not load [AssemblyName].</ExceptionMessage>
<InnerExceptionMessage>Method not found: 'Void Microsoft.FxCop.Sdk.Introspection.CallGraph.RecordStringConstantLoad(System.String)'.</InnerExceptionMessage>
<InnerStackTrace> at Microsoft.FxCop.Engines.Introspection.LoadVisitor.ReviewAttributes(AttributeList attributes, Node node)
at Microsoft.FxCop.Engines.Introspection.LoadVisitor.VisitModule(Module module, TargetModule target)
at Microsoft.FxCop.Engines.Introspection.BaseVisitor.VisitAssembly(AssemblyNode assembly, TargetFile target)
at Microsoft.FxCop.Engines.Introspection.LoadVisitor.VisitAssembly(AssemblyNode assembly, TargetFile target)
at Microsoft.FxCop.Engines.Introspection.LoadVisitor.Load(TargetFile target, Boolean buildTree, Boolean queueItems, AssemblyNode loadedAssembly)
at Microsoft.FxCop.Engines.Introspection.IntrospectionAnalysisEngine.LoadTargets(TargetFile target)
at Microsoft.FxCop.Common.EngineManager.LoadTargets(TargetFile target, Boolean resetCounts, String loadEngine)
<Exception Keyword="CA0052" Kind="Engine">
<ExceptionMessage>No targets were selected.</ExceptionMessage>

After spending some time investigating this, it appears that this is caused by an incomplete install of the service pack, causing SP1 binaries to be intermixed with RTM binaries.

Due to the way that the update was designed, depending on the number of Visual Studio products you have installed, it could attempt to install multiple times. For example, if you have both Team Foundation Client (TFC) and Visual Studio Team Suite installed, then the installer will run twice; once for TFC and once for Team Suite. If you cancel the second installation or it fails, then this will put your Visual Studio install in an incomplete state, thereby causing the above error to occur.

To fix this, simply re-run the install.