CA2122:不要间接公开具有链接要求的方法。如何在我的代码中修复它

发布于 2024-08-26 03:15:00 字数 488 浏览 3 评论 0原文

CA2122:不要间接公开具有链接要求的方法。

我的代码如下:

public void LoadPage(Uri url)
{
    webBrowser1.Url = url;    //webBrowser1 is an object of WebBrowser
    webBrowser1.Refresh();
}

Fxcop 产生警告“CA2122:不要间接公开具有链接要求的方法”。

  1. 为什么这个警告出现在我的代码上?

  2. 如何解决?

  3. 如何向我的代码授予权限以填充代码访问安全 (CAS) 属性。即我在这样的方法上有一个属性 [EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = false)]

我向我的代码授予了哪些权限以及如何获取上述属性?

CA2122: Do not indirectly expose methods with link demands.

My code is as follows:

public void LoadPage(Uri url)
{
    webBrowser1.Url = url;    //webBrowser1 is an object of WebBrowser
    webBrowser1.Refresh();
}

Fxcop produced the warning "CA2122: Do not indirectly expose methods with link demands."

  1. Why this warning appeared on my code?

  2. How to fix it?

  3. How can I grant permission to my code to fullfill Code access security (CAS) attribute. i.e I have an attribute on a method like this
    [EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = false)]

What permission I have give my code and How for above mentioned attribute?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文