Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix FxCop error code 512?

While refactoring, moving around some assemblies around, etc. I compiled a solution in Visual Studio and got back a single error message: "FxCop exited with error code 512". The build seems fine other than this one error.

Anyone know what this actually means in detail? Where might I start looking to figure out how to fix it? Setting FailOnError to false is not a path I want to go down.

like image 922
Nick W. Avatar asked Oct 31 '11 03:10

Nick W.


2 Answers

I found a solution. It was because I was referencing an assembly with a higher version and FxCop was complaining about it with warning CA0060 further down. The solution is to edit the FxCopCmd.exe.config file and change

<add key="AssemblyReferenceResolveMode" value="StrongName" />

to

<add key="AssemblyReferenceResolveMode" value="StrongNameIgnoringVersion" />
like image 35
magritte Avatar answered Nov 12 '22 11:11

magritte


The other answers are all on the right track but miss one small part.

  • Suppressing is an option but you might hide an error regarding an important dll and that's not a good thing.
  • Random dependency directory is prone to error.
  • Xml reports are the place to look but the FxCop MSBuild Task doesn't reveal where it puts them :(

In order to run FxCop from the command line I had to execute the following:

FxCopCmd.exe /f:<Assembly.dll> /o:<OutputFileName> /verbose

FxCopCmd is what is MSBuild Task uses. It will return error code 512 if there is a missing assembly even if the assembly is not needed for it to run. See the below FxCop message:

The indirectly-referenced assembly 'Newtonsoft.Json, Version=4.0.2.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' could not be found. This assembly is not required for analysis, however, analysis results could be incomplete. This assembly was referenced by: Removed.dll.

Add the reference to that dll and then the error code disappears.

like image 170
JohnDRoach Avatar answered Nov 12 '22 12:11

JohnDRoach