Question

I am attempting to run FxCopCmd 10.0 through Sonar-runner. However, FxCop is returning an error even though it generates an analysis report. Since it returns an error, sonar-runner does not slurp the report.

To isolate the issue I have run FxCopCmd from the prompt.

The console error message returned is:

  • Error(s) occurred during FxCop initialization:
  • 'Rules' directory in settings file has bad format or does not exist.

I get the same error whether I run FxCop 10.0, or 1.36. If I create a brand new empty project using the FxCop Gui, and then open it, the Gui reports the same error message, but it shows all the rules.

The log shows that FxCop completed the analysis and output 78 messages. The report contains the 78 messages. It also appears to have found the rules.

I am at a loss on what to check next.

COMMAND ISSUED

C:\svn\system-sr\tools\fxcop-10.0\FxCopCmd.exe /p:C:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\.sonar\sonar.FxCop /out:C:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\.sonar\fxcop-report.xml /f:C:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\bin\com.me.mySystem.dll /igc /to:600 /gac /v  > verbose.log

END OF VERBOSE LOG

Cleaning Up Rules...
Analysis Complete.
Writing 78 messages...
Writing report to C:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\.sonar\fxcop-report.xml...
Done:00:00:02.5852585

PARTIAL CONTENTS of FxCop report (Full report contains 78 messages as indicated in log)

   <!-- snipped -->
          <Member Name="#MaintainStrataSelection()" Kind="Method" Static="False" Accessibility="Private" ExternallyVisible="False">
           <Messages>
            <Message Id="System.Int32.Parse(System.String)" TypeName="SpecifyIFormatProvider" Category="Microsoft.Globalization" CheckId="CA1305" Status="Active" Created="2013-05-03 15:45:07Z" FixCategory="NonBreaking">
             <Issue Name="IFormatProviderAlternate" Certainty="95" Level="Error" Path="c:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\UserControl" File="ConfirmSubmitUserControl.ascx.cs" Line="388">Because the behavior of 'int.Parse(string)' could vary based on the current user's locale settings, replace this call in 'ConfirmSubmitUserControl.MaintainStrataSelection()' with a call to 'int.Parse(string, IFormatProvider)'. If the result of 'int.Parse(string, IFormatProvider)' will be based on input from the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will based on input stored and accessed by software, such as when it is loaded from disk or from a database, specify 'CultureInfo.InvariantCulture'.</Issue>
            </Message>
           </Messages>
          </Member>
          <Member Name="#Page_PreRender(System.Object,System.EventArgs)" Kind="Method" Static="False" Accessibility="Family" ExternallyVisible="True">
           <Messages>
            <Message Id="System.Int32.Parse(System.String)" TypeName="SpecifyIFormatProvider" Category="Microsoft.Globalization" CheckId="CA1305" Status="Active" Created="2013-05-03 15:45:07Z" FixCategory="NonBreaking">
             <Issue Name="IFormatProviderAlternate" Certainty="95" Level="Error" Path="c:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\UserControl" File="ConfirmSubmitUserControl.ascx.cs" Line="105">Because the behavior of 'int.Parse(string)' could vary based on the current user's locale settings, replace this call in 'ConfirmSubmitUserControl.Page_PreRender(object, EventArgs)' with a call to 'int.Parse(string, IFormatProvider)'. If the result of 'int.Parse(string, IFormatProvider)' will be based on input from the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will based on input stored and accessed by software, such as when it is loaded from disk or from a database, specify 'CultureInfo.InvariantCulture'.</Issue>
            </Message>
           </Messages>
          </Member>
          <Member Name="#UpdatePageSelectedItems()" Kind="Method" Static="False" Accessibility="Private" ExternallyVisible="False">
           <Messages>
            <Message Id="System.Int32.ToString" TypeName="SpecifyIFormatProvider" Category="Microsoft.Globalization" CheckId="CA1305" Status="Active" Created="2013-05-03 15:45:07Z" FixCategory="NonBreaking">
             <Issue Name="IFormatProviderAlternateString" Certainty="95" Level="Error" Path="c:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\UserControl" File="ConfirmSubmitUserControl.ascx.cs" Line="507">Because the behavior of 'int.ToString()' could vary based on the current user's locale settings, replace this call in 'ConfirmSubmitUserControl.UpdatePageSelectedItems()' with a call to 'int.ToString(IFormatProvider)'. If the result of 'int.ToString(IFormatProvider)' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.</Issue>
             <Issue Name="IFormatProviderAlternateString" Certainty="95" Level="Error" Path="c:\svn\system-sr\src\com.me.mySystem\com.me.mySystem\UserControl" File="ConfirmSubmitUserControl.ascx.cs" Line="512">Because the behavior of 'int.ToString()' could vary based on the current user's locale settings, replace this call in 'ConfirmSubmitUserControl.UpdatePageSelectedItems()' with a call to 'int.ToString(IFormatProvider)'. If the result of 'int.ToString(IFormatProvider)' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'.</Issue>
            </Message>
           </Messages>
          </Member>
         </Members>
        </Type>
       </Types>
      </Namespace>
     </Namespaces>
    </Module>
   </Modules>
  </Target>
</Targets>
<Rules>
   <!-- snipped -->
</Rules>
<Localized>
   <!-- snipped -->
</Localized>
<DebugInfo>
   <!-- snipped -->
  </SearchPaths>
  <ResolvedAssemblies>
   <!-- snipped -->
  </ResolvedAssemblies>
</DebugInfo>
<Exceptions>
  <Exception Keyword="CA0001" Kind="Initialization">
   <Type>Microsoft.FxCop.Sdk.FxCopException</Type>
   <ExceptionMessage>'Rules' directory in settings file has bad format or does not exist.</ExceptionMessage>
  </Exception>
</Exceptions>
</FxCopReport>
Was it helpful?

Solution

I resolved this issue by deleting the xml configuration files in the directory %USERPROFILE%\AppData\Roaming\Microsoft FxCop\1.32\

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top