SL程序集问题

djjliufong 2010-02-01 09:16:47
using System.Net;
我在SL项目里引用了这个后.

为什么点不出 System.Net.WebClient这个类? 装的VS2008 ,SP1已打.高手帮忙啊..
...全文
129 8 打赏 收藏 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
xingjunli 2010-02-20
  • 打赏
  • 举报
回复
只要装好的开发工具包,新建项目System.Net.dll已做了引用的不需要再手动添加
正确的DLL是:
C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\System.Net.dll
djjliufong 2010-02-18
  • 打赏
  • 举报
回复
怎么看引用的是.net Framework3.5里的WebClicent 还是Silverlight里的WebClicent呢?

右键项目 添加引用 然后点哪个面板里添加system.net? 我打开SL安装目录下找到system.net.dll这个文件,然后引用的时候,系统自己在SL项目里新建了一个文件夹,把和system.net.dll这个文件一个目录的所有dll文件都引用进来了。这是怎么回事呢?
jv9 2010-02-02
  • 打赏
  • 举报
回复
Silverlight属于客户端技术,出于安全原因,微软禁止从客户端使用WebClient类。
详细,看MSDN解释:


A WebClient instance does not send optional HTTP headers by default. If your request requires an optional header, you must add the header to the Headers collection.

Some headers are considered restricted and are either exposed directly (such as Content-Type) or protected by the system and cannot be set in a WebHeaderCollection object. Any attempt to set one of these restricted headers in the WebHeaderCollection object using the Item[([(HttpRequestHeader])]) or Item[([(String])]) property or throws an exception. If the WebHeaderCollection object is associated with a HttpWebRequest object, the exception is thrown by the Item[([(HttpRequestHeader])]) property. If the WebHeaderCollection object is associated with a WebClient object, the exception is thrown when an attempt to send the WebClient request occurs.

For a list of restricted headers, see the Remarks in the WebHeaderCollection class.

Silverlight version 2 includes support for cross-domain connectivity which allows an application to access resources from locations other than the site of origin. This is an important feature for enabling Silverlight applications to consume existing services on the web. The security policy system in the Silverlight 2 runtime now requires that a policy file be downloaded from a network resource before a network connection is allowed access to that resource. This security policy system affects cross-domain network access for WebClient and HTTP classes in the System.Net namespace. Network connections for WebClient and HTTP classes to the site or host of origin do not require a security policy. For more information, see Network Security Access Restrictions in Silverlight.

For security reasons, the Silverlight 2 runtime restricts access to certain classes of URLs from the WebClient and HTTP classes in the System.Net namespace. There are similar access restrictions applied by the Silverlight 2 runtime to other classes including the Image and MediaElement classes in the System.Windows.Controls namespace. The Silverlight 2 runtime also applies access restrictions to XAML source files and font files based on the class of URL.

The connections affected are access to cross-zone, cross-domain, and cross-scheme URLs. These restrictions are designed to prevent networking threats (for example, threats based on a Silverlight 2 application run from an internet server getting access to resources on a local intranet server). For more information, see URL Access Restrictions in Silverlight.



http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.95).aspx
Goldfire_001 2010-02-02
  • 打赏
  • 举报
回复
弱弱的问一句,童鞋。。

你的System.Net用的谁的啊?.net Framework3.5的还是Silverlight 的 .NET Framework 类库

这两个可是都有WebClient啊。

Jv9说的应该是.net Framework3.5里的WebClient吧。
而,edward说的是Silverlight的WebClient吧。
zhuzhi 2010-02-02
  • 打赏
  • 举报
回复
先确认是否添加了System.Net.dll引用。再就是编译一下,看有没有错误,有时候可能IDE有问题,智能提示没有出来。
HarveyYan 2010-02-02
  • 打赏
  • 举报
回复
Silverlight客户端可以使用WebClient类哦,楼上的理解有误。看看中文的说明:
http://msdn.microsoft.com/zh-cn/library/system.net.webclient(VS.95).aspx
纷享刘晨 2010-02-02
  • 打赏
  • 举报
回复
可以用WebClient

确认一下装了Tools
HarveyYan 2010-02-01
  • 打赏
  • 举报
回复
添加引用了没有?项目》》引用(右键)》》添加引用

8,757

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧