在它的非常基本的形式中,我在后面的 Page.xaml 代码中有一些 xml 的 WebClient 请求。就像是:
public Page()
{
InitializeComponent();
Uri uri = new Uri("Dummy.xml", UriKind.Relative);
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(uri);
}
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
//Do something
}
}
如果我将我的 Silverlight 项目设置为通过 asp.net 托管页面运行,然后将 Dummy.xml 放入 ClientBin 文件夹(相对于 xap),它工作正常。
如果我只使用自动生成的测试页选项设置项目,并再次将 xml 与 xap 相关,则请求不起作用(尽管完成的事件确实会触发)。
我的问题是为什么?是否要求任何动态下载的 Silverlight 项目都必须在服务器上?
干杯J