How to fix FxCop error code 512?

Nick W. picture Nick W. · Oct 31, 2011 · Viewed 7.8k times · Source

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.

Answer

JohnDRoach picture JohnDRoach · May 3, 2013

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.