开发者

Conflicting information in the MSDN and compiler warnings

I am trying to use FtpWebRequest.Proxy and have it set to GlobalProxySelection.GetEmptyWebProxy() however i get a compliler warning

Warning 1 'System.Net.GlobalProxySelection' is obsolete: '"This class has been deprecated. Please use WebRequest.DefaultWebProxy instead to access and set the global default proxy. Use 'null' instead of GetEmptyWebProxy. http://go.microsoft.com/fwlink/?linkid=14202"'

it reccomends to use null, but from FtpWebRequest.Proxy's page under the execpt开发者_如何学Pythonions section it says

ArgumentNullException - This property cannot be set to null.

What is the correct thing to do?


That is confusing. But looking at the decompiled code for the setter of that property it doesn't look like it will throw that exception if you set it to null. I'd suggest the documentation is out of date and set it to null. It should be quickly apparent whether you get an exception or not...


You're right. That's confusing.

The answer appears to be to use the WebRequest.DefaultWebProxy property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜