CA2109 - 忽略还是不忽略 - 这就是问题
在我和朋友一起编写的程序中,我们收到此警告:CA2109。 在查看了 MSDN 之后,我很困惑这是否是我需要关心的事情。
MSDN VS2008: http://msdn.microsoft.com/en- us/library/ms182312(v=VS.90).aspx
MSDN VS2010: http://msdn.microsoft.com/en-us/library/ms182312.aspx
这两个版本之间的区别在于此部分取自 VS2008 MSDN,但在 VS2010 MSDN 中不存在:
注意此规则仅适用于 .NET Framework 2.0 之前的版本。您可以在 .NET Framework 2.0 版及所有更高版本中抑制此警告。在这些更高版本中,出于安全需求,运行时会自动确保委托的创建者在堆栈遍历期间位于调用堆栈中。
有什么建议吗?
编辑:只是为了在阅读 DGH 答案后澄清 - 正如 MSDN2008 中的注释中所述,我可以忽略它,因为编译器正在处理这个问题。我的问题是 VS2010 中发生了什么,这个注释不存在。
In a program I am writing with a friend we get this warning: CA2109.
After looking at the MSDN I was quite puzzled if this is something I need to be concern about or not.
MSDN VS2008:
http://msdn.microsoft.com/en-us/library/ms182312(v=VS.90).aspx
MSDN VS2010:
http://msdn.microsoft.com/en-us/library/ms182312.aspx
The difference between these 2 versions is this section that is taken from the VS2008 MSDN but doesn't exist in the VS2010 MSDN:
Note This rule only applies to versions of the before .NET Framework version 2.0. You can suppress this warning in .NET Framework version 2.0 and all later versions. In these later versions, the runtime automatically makes sure that the creator of the delegate is in the callstack during a stack walk for a security demand.
Any suggestions?
EDIT: Just to clarify after reading DGH answer - As described in the note in MSDN2008 I can ignore it because the compiler is dealing with this. My question is what is going on in VS2010 where this note doesn't exist.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个潜在的安全问题。如果代码仍然可以编译并运行(警告不应阻止),那么您当然可以忽略它继续前进。但是,如果您希望程序具有尽可能高的安全级别,您可能应该考虑按照这些 MSDN 文章的建议解决此问题。
It is a potential security concern. If the code still compiles and runs (which warnings shouldn't prevent), then you certainly can ignore it an move on. However, if you wish to have the highest possible level of security for your program, you should probably consider addressing this issue as recommended by those MSDN articles.