简体   繁体   English

无代码禁止警告

[英]Suppress warning without code

I am trying to suppress some warnings in Visual Studio, but the problem is that they don't have a code or anything I could use to identify them(or I can't find it). 我试图在Visual Studio中抑制一些警告,但问题是他们没有代码或我可以用来识别它们的任何东西(或者我找不到它)。

Most of these errors look like "The referenced component could not be loaded" or 'cannot find custom tool on this system'. 大多数这些错误看起来像“无法加载引用的组件”或“无法在此系统上找到自定义工具”。

Both these type of errors appear on the Error List tab from visual studio, but they don't appear in the Output tab, where I could see their' code also. 这两种错误都出现在visual studio的“错误列表”选项卡上,但它们没有出现在“输出”选项卡中,我也可以看到它们的“代码”。

If anyone could give me some tips about how to suppress them, would be great. 如果有人能给我一些关于如何抑制它们的提示,那就太好了。

It is still recommanded to solve warnings rather than suppressing them. 仍然建议解决警告而不是抑制警告。

But if you are pretty much sure that things you have done that causes the warning is meaningful and logically correct, you can still suppress them. 但是,如果你非常确定你所做的事情导致警告是有意义的并且在逻辑上是正确的,你仍然可以抑制它们。

Check the warning codes that Visual Studio generates and get rid of the CS prefix 检查Visual Studio生成的警告代码并删除CS前缀

Add the following code into your .csproj file within a PropertyGroup tag (without Condition property) 将以下代码添加到PropertyGroup标记中的.csproj文件中(不带Condition属性)

<NoWarn>THE_WARNING_CODE</NoWarn>

If you wish multiple warning codes to be suppressed, separate them by semicolon. 如果希望抑制多个警告代码,请用分号分隔。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM