Silverlight WebRequest 失败并显示“无法识别 URI 前缀”

发布于 2024-08-20 17:53:08 字数 345 浏览 6 评论 0原文

我有一个 silverlight 库,应该发出 Web 服务请求并接收 xml 响应:

   Uri uri = new Uri("http://some_server:51306/getStuff.xml?id=14");            
   WebRequest request = WebRequest.Create(uri);

但是,WebRequest.Create(uri) 失败,出现异常“无法识别 URI 前缀”。

请注意,我正在使用来自非 silverlight dll 的单元测试来运行该程序。我需要为该应用程序构建一个测试套件!

有什么想法吗?

I have a silverlight library that is supposed to get make a web service request and receive an xml response:

   Uri uri = new Uri("http://some_server:51306/getStuff.xml?id=14");            
   WebRequest request = WebRequest.Create(uri);

However, WebRequest.Create(uri) fails with the exception "The URI prefix is not recognized".

Note that I am running the program using a unit test from a non-silverlight dll. I need to build a test suite for the app!

Any ideeas?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

呆萌少年 2024-08-27 17:53:08

尝试将 .Web 项目设置为默认启动项目而不是 Silverlight 项目

Try setting the .Web project as the default startup project instead of the Silverlight project

千鲤 2024-08-27 17:53:08

您是否尝试过将第二个参数添加到 Uri 构造函数中?

 Uri uri = new Uri("http://some_server:51306/getStuff.xml?id=14", UriKind.Absolute);  

Have you tried adding the second parameter to the Uri constructor?

 Uri uri = new Uri("http://some_server:51306/getStuff.xml?id=14", UriKind.Absolute);  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文