【发布时间】:2011-08-01 16:40:58
【问题描述】:
我有一个 MonoTouch 项目,它使用了一些与 Windows Phone 7 应用程序共享的代码。此共享代码为使用 SLSvcUtil.exe 生成的 RIA 域服务(使用 /Soap 端点)创建 WCF 代理。代码是这样的:
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://someurl/someservice.svc");
var client = new MyDomainServiceSoapClient(binding, address);
client.CookieContainer = _cookieContainer; // <-- EXCEPTION here
这段代码在 WP7 中有效,但在 MonoTouch 中失败,我找不到原因。我在 MonoTouch 中遇到的例外是:
System.InvalidOperationException: Unable to set the CookieContainer.
Please make sure the binding contains an HttpCookieContainerBindingElement.
at MyDomainServiceSoapClient.set_CookieContainer
我在设置 CookieContainer 之前尝试了以下选项,但仍然是同样的错误:
binding.EnableHttpCookieContainer = true;
binding.AllowCookies = true;
binding.CreateBindingElements()
.Add(new HttpCookieContainerBindingElement()); // ??
更新:我也尝试过手动构建一个 CustomBinding 并添加一个 HttpCookieContainerBindingElement 但这也行不通。
有什么想法吗? MonoTouch 网站告诉我 WCF 实现是“实验性的”,所以这可能是当前 MonoTouch 版本的限制?
【问题讨论】:
-
这个问题似乎在 MonoTouch 4.0.4.1 中再次出现。在 4.0.3 中一切正常。你有没有找到解决它的方法?
-
我可以确认问题在 MT 4.0.7 中仍然存在
标签: wcf windows-phone-7 xamarin.ios cookiecontainer