Frequently Asked Questions

Installation
Question
I cannot get FxCopCmd to work as an external tool in Visual Studio. What can be the problem?
Answer
Inspect the settings in the External Tools dialog box.

 

Question
Can FxCop be used in a side-by-side installation of the .NET Framework?
Answer
Yes.

Loading/Analysis
Question
Why won't FxCop load some of my assemblies?
Answer
FxCop only loads and analyzes managed code assemblies. The following are the major reasons an assembly fails to load:

Question

·         Why doesn't FxCop resolve the source locations of all messages?

·         I built my assemblies with debug information. Why does <PDB not available or source lookup disabled> show up in the Source field of the Message dialog box?

·         What does <Unknown File> in the Source field of the Message dialog box mean?

Answer
FxCop requires program debug database (PDB) files in order to provide source locations.

 

Question
Messages are displayed in the UI when I analyze a project. Why aren't messages written when I analyze the same project on the command-line? When I include the /summary switch, it shows that messages were generated.
Answer
The console message output depends on the report options set in the project file. By default, all active messages are written to the console. To verify this setting, from the Project menu, select Options to display the Project Options dialog box. In the Save Messages group, the Active checkbox for a report should be selected.

Rules
Question
I need help understanding the FxCop rules.
Answer
Additional information on a rule is available by double-clicking the rule and then selecting the URL link under the Support tab.

Question
I have developed some custom rules that I would like to share with others. Is there somewhere I can post these rules?
Answer
Go to GotDotNet User Samples and filter on FxCop in the "All related products" drop-down list.

Question
The message from the Virtual methods and their overrides require the same LinkDemand status rule states that I should add a LinkDemand to my code. I do not have the source code for the virtual method. How do I find which permission to link demand?
Answer
Use the Permissions View tool (Permview.exe), with the /decl option, to examine the assembly containing the virtual method. The /decl option displays all declarative security at the assembly, class, and method level for the assembly.

Question
I get lots of CultureInfoShouldBePassed messages on code generated by the VS IDE, specifically from the InitializeComponent method of a form. The note just before the method states "do not modify the contents of this method." How can I fix these?
Is there any way of telling the Visual Studio.NET Designer to use CultureInfo.InvariantCulture?
Answer
The CultureInfoShouldBePassed rule alerts a developer to all culture-aware overloads and requires an explicit decision of whether a global audience is expected. There currently is not a way to tell the VS.Net designer to specify a CultureInfo.InvariantCulture. However, you can safely exclude these FxCop messages on code generated by Visual Studio.

Miscellaneous
Question
How can I add custom words to the FxCop dictionary? How can I add project specific dictionaries?
Answer
Create a file named CustomDictionary.xml. Add the following XML structure, with the new words (case insensitive) under the <Recognized> node.

<Dictionary>
    <Words>
        <Recognized>
               <Word>
aNewWord</Word>
               <Word>
AnotherNewWord</Word>
        </Recognized>
    </Words>
</Dictionary>

To use the dictionary with all projects, place the file in the FxCop install directory (usually C:\Program Files\Microsoft FxCop). For project-specific dictionaries, place the file in a separate directory along with the project file. For the words to be recognized, you must close and restart FxCop after creating or modifying the custom dictionary.

Question
How can we share a project/report file among our group when we have different directory/drive structures?
Answer
Instead of using the Shared Project option, which requires all files to be on the same drive, do the following: