Error loading rule "ViewStateUserKeyShouldBeSet"


Install the rules into C:\Program Files (x86)\Microsoft Fxcop 10.0\Rules\
Start FxCop
A dialog with the following error message is displayed twice:
    Error(s) Loading Project
    Error Message
    Error loading rule "ViewStateUserKeyShouldBeSet": The rule "Microsoft Rules.Managed.CA5332" has already been added from another rule assembly.
    The project was still loaded, but values may not have been set correctly.
There is a rule CA5332 MarkVerbHandlersWithValidateAntiforgeryToken in rule library ASP.NET MVC Security Rules
There NOT a rule CA5332 ViewStateUserKeyShouldBeSet anywhere.
Delete AspNetMvcSecurityRules.dll.
FxCop now loads without error.
Rule CA5332 ViewStateUserKeyShouldBeSet is present in ASP.NET Security Rules.
... I.e., the same rule number, CA5332 is present in both AspNetMvcSecurityRules.dll and AspNetSecurityRules.dll, and it is called different things in each place.
Environment: Visual Studio 2010 Professional, FxCop 10.0


alexandrul wrote Jan 27, 2011 at 7:16 AM

Changing the CheckId of MarkVerbHandlersWithValidateAntiforgeryToken enables the loading of both rule assemblies.

oakmario wrote Aug 5, 2011 at 5:14 PM

I have this same problem. How do you change the CheckId in the assembly?

wrote Aug 5, 2011 at 5:17 PM

Strachan wrote Aug 11, 2011 at 2:17 AM

I worked around the problem by downloading the source code and in the AspNetMvcSecurityRules project, changing the problematic rule's ID from CA5332 to CA9999, then building and copying the resultant DLL into the FxCop rules directory (renaming the old DLL to .dxx for safekeeping).

wrote Oct 18, 2011 at 2:00 PM

wrote Dec 22, 2011 at 4:06 PM

wrote Feb 14, 2013 at 2:00 AM