如何在 Windows Phone 7 中设置 MaxBufferSize/MaxReceivedMessageSize?

发布于 2024-12-17 07:43:23 字数 951 浏览 6 评论 0原文

我在从 Windows Phone 7 应用程序查询 Web 服务器信息时遇到问题,根据我的研究,我追溯到 MaxBufferSize/MaxReceivedMessageSize 太低。问题是,我不知道如何改变它。我找到的每个搜索结果都谈到该应用程序是 WCF 应用程序,并更改 ServiceReferences.ClientConfig 中的绑定。 这篇文章 中的解决方案给出了这个示例:

1. edit the ServiceReferences.ClientConfig to accept a large buffer.

 <binding name="BasicHttpBinding_MosaicService" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">  

但是,我没有使用 WCF 应用程序,并且我不知道上面的等价物是什么,以及 ServiceReferences.ClientConfig 对于常规 WP7 应用程序。有人可以给我一些帮助吗?我已经尽力自己解决这个问题,但我一无所获。

作为参考,万一其他人遇到了我遇到的问题(花了很长时间才弄清楚这可能是问题所在),这就是我身上发生的事情:我收到一个带有以下消息的 WebException:“远程服务器返回错误:NotFound”抛出。堆栈跟踪的相关部分是:

at System.Net.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

I've been having trouble querying a web server for information from my Windows Phone 7 app, and from my research, I've traced it back to MaxBufferSize/MaxReceivedMessageSize being too low. The problem is, I can't figure out how to change it. Every search result I find talks about the application being a WCF app, and to change the binding in ServiceReferences.ClientConfig. The solution from this post gives this example:

1. edit the ServiceReferences.ClientConfig to accept a large buffer.

 <binding name="BasicHttpBinding_MosaicService" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">  

However, I'm not using a WCF app, and I don't know what the equivalents of the above, and ServiceReferences.ClientConfig are for a regular WP7 application. Can anyone give me some help with this? I've done my best to figure it out myself but I'm getting nowhere.

For reference, in case someone else is having the problem I was (it took a really long time to figure out that this may be the problem), this is what is happening to me: I'm getting a WebException with the message: "The remote server returned an error: NotFound" thrown. And the relevant section of the stacktrace is:

at System.Net.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

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

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

发布评论

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

评论(1

贪了杯 2024-12-24 07:43:23

我不确定您如何从错误消息“远程服务器返回错误:NotFound”转变为认为您的客户端无法处理响应的大小。更有可能的是,错误消息是正确的,但找不到您请求的 URL。在您启动请求的代码中放置一个断点。 HttpWebRequest 对象上的 RequestUri 属性设置为什么?将该 URL 复制到浏览器中,您很可能会看到“找不到页面”。修正你不正确的网址,一切都会好起来的。

I'm not sure how you went from the error message "The remote server returned an error: NotFound" to thinking that your client can't handle the size of the response. Much more likely, the error message is correct and the URL you are requesting can't be found. Drop a breakpoint in your code where you kick off the request. What is the RequestUri property set to on your HttpWebRequest object? Copy that URL into a browser and you'll more than likely see that you get a "page not found". Fix your incorrect URL and all will be well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文