It appears that sometimes FxCop displays a link to the source line and file in the Message Details window and sometimes it doesn't. Why this inconsistent behavior?
There are three usual reasons why this occurs:
- Source lookup is disabled. To turn source lookup on, choose Project -> Options and check Attempt source file lookup.
- The Program Database (PDB) is not present or it is out-of-date. Starting in Visual Studio 2005, this file is now built by default both in Debug and Release. Make sure it was built at the same time and is alongside the assembly under analysis.
- There is no source information for the code element that warning was raised against. FxCop and Visual Studio Code Analysis both use the information stored in the Program Database (PDB) file to map members back to a particular source file. Unfortunately, because this file was orginally only designed for use by a debugger, it only contains information about actual executable code. This means that FxCop cannot find non-executable code such as namespaces, types, fields, interface methods and abstract methods.
Note: Visual Studio Code Analysis does not suffer this problem to extent of FxCop - it falls back to the Visual Studio Code Model to find elements that do not exist in the PDB. It still, however, is unable to find namespaces.