WPF 应用程序:Microsoft.Maintainability#CA1506 签名无效 FxCop 违规

发布于 2024-11-10 18:43:56 字数 438 浏览 4 评论 0原文

我有一个 WPF 解决方案,当我在其上运行 FxCop 时(准确地说,当我在启用代码分析的情况下构建它时),规则集设置为 Microsoft 所有规则(还有一些其他规则集可以执行此操作) ,以及),它给了我以下错误:

CA0001: Rule=Microsoft.Maintainability#CA1506, Target=My.Project.Namespace.App : Signature is not valid.

这似乎指的是作为我的应用程序入口点的 Application 子类。据我所知,类签名似乎没有什么是无效的。谷歌搜索该错误,发现了一些其他 CA0001/CA1506 违规行为,但没有具体涉及“签名无效”。错误(CA1506似乎是“避免过度的类耦合”,尽管我发现有人有我的错误,但“集合在枚举期间被修改”;这和我的错误似乎都与过度耦合无关)。

I have a WPF solution, and when I run FxCop on it (well, when I build it with Code Analysis enabled, to be precise), with the rule set set to Microsoft All Rules (there are a few other rule sets that do this, as well), it gives me the following error:

CA0001: Rule=Microsoft.Maintainability#CA1506, Target=My.Project.Namespace.App : Signature is not valid.

This seems to refer to the Application subclass that is my application's entry point. Nothing seems to be invalid about the class signature, as far as I can tell. Googling the error brought up some other CA0001/CA1506 violations, but nothing specifically regarding the "Signature is not valid." error (CA1506 seems to be "Avoid excessive class coupling", although I found someone with my kind of error but with "Collection was modified during enumeration"; neither that nor my error seem to have anything to do with excessive coupling).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

So要识趣 2024-11-17 18:43:56

根据 CA001 文档,此错误是由自定义规则中的缺陷托管代码分析工具中的未知缺陷引起的。听起来该错误正在报告代码分析引擎由于签名无效而无法加载/执行 CA1506 规则,但由于您使用的是标准 Microsoft 规则集,这似乎是一个令人费解的错误。

MSDN 文档建议您尝试以下操作:

  • 有关更多诊断信息,请查看 \obj 文件夹中的 CodeAnalysisReport.xml。报告列出了所有内部异常的异常类型、堆栈、类型、消息和堆栈。
  • 尝试重写报告错误的行,或该行周围的几行代码。

如果检查代码分析报告没有产生其他信息,您可能需要检查您的开发环境,看看 Visual Studio 中配置代码分析的方式是否存在问题。您甚至可以尝试在 Visual Studio 上进行修复。

According to the CA001 documentation, this error is caused by a defect in a custom rule or an unknown defect in the managed code analysis tool. It sounds like the error is reporting that the code analysis engine is unable to load/execute the CA1506 rule due to an invalid signature, but since you are using the standard Microsoft rule sets this seems to be a puzzling error.

The MSDN documentation suggests you try the following:

  • For more diagnostic information, view the CodeAnalysisReport.xml in the \obj folder. The report lists the exception type, stack, type, message, and stack of all inner exceptions.
  • Try rewriting the line where the error is reported, or several lines of code surrounding that line.

If an examination of the code ananlysis report does not yield additional information, you may want to check your development environment to see if there is an issue with the way code analysis is configured within Visual Studio. You might even try to do a repair on Visual Studio.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文