Question

I have a MonoTouch project using some code I share with a Windows Phone 7 app. This shared code creates a WCF proxy for a RIA Domain Service (using the /Soap endpoint), generated using SLSvcUtil.exe. This is what the code looks like:

BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://someurl/someservice.svc");

var client = new MyDomainServiceSoapClient(binding, address);
client.CookieContainer = _cookieContainer; // <-- EXCEPTION here

This piece of code works in WP7, but fails in MonoTouch, and I can't find why. The exception I get in MonoTouch is:

System.InvalidOperationException: Unable to set the CookieContainer.
Please make sure the binding contains an HttpCookieContainerBindingElement.
    at MyDomainServiceSoapClient.set_CookieContainer

I have tried the following options before setting the CookieContainer, but still the same error:

binding.EnableHttpCookieContainer = true;
binding.AllowCookies = true;
binding.CreateBindingElements()
    .Add(new HttpCookieContainerBindingElement()); // ??

Update: I have also tried building a CustomBinding by hand and adding an HttpCookieContainerBindingElement but this also won't work.

Any ideas? The MonoTouch site tells me that the WCF implementation is "experimental", so maybe this is a limitation in the current version of MonoTouch?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top