FxCop初始化错误CA0001

时间:2013-05-03 16:50:51

标签: fxcop fxcopcmd

我试图通过Sonar-runner运行FxCopCmd 10.0。但是,即使FxCop生成分析报告,它也会返回错误。由于它返回错误,声纳 - 跑步者不会啜饮报告。

为了隔离问题,我从提示符运行了FxCopCmd。

返回的控制台错误消息是:

  
      
  • FxCop初始化期间发生错误:
  •   
  • 设置文件中的“规则”目录格式错误或不存在。
  •   

无论是运行FxCop 10.0还是1.36,我都会得到同样的错误。如果我使用FxCop Gui创建一个全新的空项目,然后打开它,Gui会报告相同的错误消息,但它会显示所有规则。

日志显示FxCop完成了分析并输出了78条消息。该报告包含78条消息。它似乎也找到了规则。

我对接下来要检查的内容感到茫然。

发出命令

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

结束日志记录

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

FxCop报告的部分内容(完整报告包含78条消息,如日志中所示)

   <!-- 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>

1 个答案:

答案 0 :(得分:0)

我通过删除%USERPROFILE%\ AppData \ Roaming \ Microsoft FxCop \ 1.32 \

目录中的xml配置文件解决了这个问题