Silverlight 4,继承WebClient

Silverlight 4,继承WebClient,第1张

概述根据建议,我在几个网页(例如 Using CookieContainer with WebClient class)中看到,我将WebClient类子类化为使用cookie: public class MyWebClient : System.Net.WebClient{} 现在,当我初始化MyWebClient时: MyWebClient wc = new MyWebClient(); 它 根据建议,我在几个网页(例如 Using CookieContainer with WebClient class)中看到,我将WebClIEnt类子类化为使用cookie:

public class MyWebClIEnt : System.Net.WebClIEnt{}

现在,当我初始化MyWebClIEnt时:

MyWebClIEnt wc = new MyWebClIEnt();

它会抛出TypeLoadException.我的 *** 作系统是windows 7(日语),因此错误消息不是英文版;我发现它与安全规则有关.可能是什么问题?

解决方法 WebClIEnt的构造函数标有SecuritySafeCritical属性.看起来这就是导致安全异常的原因.我尝试将相同的属性应用于MyWebClIEnt的构造函数,但这不起作用.从我读过的内容来看,Silverlight中不允许这样的事情.例如,请参阅 this other question.

作为参考,确切的异常消息是:

System.TypeLoadException

inheritance security rules violated while
overrIDing member: ‘MyWebClIEnt..ctor()’. Security accessibility of
the overrIDing method must match the security accessibility of the
method being overrIDen.

我希望有更好的答案……

总结

以上是内存溢出为你收集整理的Silverlight 4,继承WebClient全部内容,希望文章能够帮你解决Silverlight 4,继承WebClient所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1007443.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存