5

I'm working on project in C#. Now I've set up a Hudson server an I've installed the .Net 4 Framework and the Windows SDK 7.1 on the server.

The project builds successfully but when I start FxCop with:

"C:\Program Files (x86)\Microsoft FxCop 1.35\fxcopcmd.exe" /file:CommonServiceTool\bin\Release /out:fxcop-result.xml

It loads all .dll rule files and after that the following exceptions happens:

Using system files at: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319.
Could not resolve reference to PresentationFramework.
Could not resolve reference to PresentationCore.
Could not resolve reference to WindowsBase.
12 exceptions occurred while loading Project1.
   00) Could not resolve type reference: [PresentationFramework]System.Windows.StartupEventArgs.
   01) Could not resolve type reference: [PresentationFramework]System.Windows.Window.
   02) Could not resolve type reference: [PresentationFramework]System.Windows.Controls.HeaderedContentControl.
   03) Could not resolve type reference: [PresentationCore]System.Windows.Input.ICommand.
   04) Could not resolve member reference: System.Windows.ThemeInfoAttribute::.ctor.

... and so on...

I'm using WPF in the project and I think FxCop can't find the WPF libraries. Can someone help me on this?

CoolKiffings
  • 567
  • 1
  • 8
  • 16

4 Answers4

4

Ensure Project -> Options... - Spelling & Analysis -> "Search Global Assembly Cache for missing references" is checked (as per FxCop and GAC Madness).

Community
  • 1
  • 1
akton
  • 14,148
  • 3
  • 43
  • 47
  • is there a command line option for that? I only use the fxcopcmd.exe – CoolKiffings Sep 05 '12 at 07:02
  • From http://msdn.microsoft.com/en-us/library/bb429449(v=vs.80).aspx, you could use the `/directory` option for each directory (since the GAC stores each folder individually). Alternatively, set "Copy Local" to true on each referenced assembly when you build the project. It is not ideal but it will at least pull all the assemblies locally. – akton Sep 05 '12 at 07:06
  • i've tried to check the "Search Global Assembly Cache for missing references" but nothing changed. I don't want to copy the references to the project. Isn't there any other way to fix that? Or do I need to install the complete MSVS on the server. Our admin doesn't want to install it, me too. – CoolKiffings Sep 05 '12 at 07:13
  • @CoolKiffings Does this occur on other computers or just the Hudson server? – akton Sep 05 '12 at 07:44
  • on both. If I use fxcopcmd.exe on my developer pc, it occurs too – CoolKiffings Sep 05 '12 at 07:52
  • @CoolKiffings Do the assembly references have "Specific Version" set to true? If so, try setting it to false. – akton Sep 05 '12 at 07:54
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/16278/discussion-between-coolkiffings-and-akton) – CoolKiffings Sep 05 '12 at 08:01
4

Are you running fxcopcmd.exe directly or via a plug-in? If the former, try adding the /gac command line switch. If you're using an intermediary runner, what is it?

Nicole Calinoiu
  • 20,843
  • 2
  • 44
  • 49
  • I've installed FxCop on our Hudson CI Server. There I start a batch command with fxcopcmd. Starting it with /gac doesn't fix the problem. – CoolKiffings Sep 11 '12 at 13:21
  • Had the same issue, problems resolving reference to System - adding /gac switch to command line fixed it. – Greg Smith Jan 04 '13 at 17:21
1

I had a similar problem with fxcopcmd V12. I was able to solve it by explicitly adding

/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\WindowsBase.dll"

See: FxCop engine exception on WPF assembly

Harry B.
  • 51
  • 2
0

Ok, I got it!

FxCop 1.35 doesn't work with WPF. Now I've installed FxCop 10.0. Now it works. But thank you all for the help!

CoolKiffings
  • 567
  • 1
  • 8
  • 16