Bug 128 - Unable to get/set CookieContainer on SlSvcUtil.exe generated domain service client
Summary: Unable to get/set CookieContainer on SlSvcUtil.exe generated domain service c...
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- major
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
Depends on:
Reported: 2011-08-01 05:05 UTC by Erik Schack Andersen
Modified: 2011-08-04 14:36 UTC (History)
2 users (show)

Tags: cookiecontainer
Is this bug a regression?: ---
Last known good build:

Simple test case (10.90 KB, application/octet-stream)
2011-08-01 10:23 UTC, Erik Schack Andersen

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Erik Schack Andersen 2011-08-01 05:05:32 UTC
I am using SlSvcUtil.exe to generate DomainService classes to access our existing WCF RIA Services server (using a soap endpoint).

However after upgrading to MonoTouch I am now unable to get/set the CookieContainer property on the generated domain service classes.

The get function always returns null and the set function throws the following exception: "System.InvalidOperationException: Unable to set the CookieContainer.
Please make sure the binding contains an HttpCookieContainerBindingElement."

Getting and setting the CookieContainer worked perfectly in MonoTouch 4.0.3.

This issue is the exact same as the one posted here: http://stackoverflow.com/questions/5425011/unable-to-set-cookiecontainer-on-service-client-in-monotouch/6895995
Comment 1 Sebastien Pouliot 2011-08-01 09:11:55 UTC
Please attach a small test case (so I'm sure I testing the same code you're hitting) and I'll track down the regression. Thanks!
Comment 2 Erik Schack Andersen 2011-08-01 10:23:32 UTC
Created attachment 45 [details]
Simple test case
Comment 3 Erik Schack Andersen 2011-08-01 10:24:52 UTC
Comment on attachment 45 [details]
Simple test case

I have attached a simple test project that shows the problem. Code runs fine on MT 4.0.3 but not
Comment 4 Sebastien Pouliot 2011-08-01 10:39:13 UTC
Comment 5 Sebastien Pouliot 2011-08-02 22:13:08 UTC
It works here. My code is more recent (than but I don't recall any WCF related changes.

			// On MT 4.0.3 the property will return a valid object. MT returns null.
			CookieContainer cookieContainer = authClient.CookieContainer;

That's not null for me.
			// MT throws an exception regardless of cookieContainer being a valid object or not. Works fine on MT 4.0.3
			authClient.CookieContainer = cookieContainer;

That works without any exception (but your exception was likely related to the null value).

Can you confirm the attached sample fails for you ? (last minute error ?) 

I'll ask around if someone has installed to compare results.
Comment 6 Erik Schack Andersen 2011-08-03 04:41:47 UTC
I just retested the attached sample on 4.0.3 and on both the simulator and on my device. On 4.0.3 cookieContainer is a valid object, but on it is null and the exception is thrown.

Setting the property will throw the exception on regardless of the cookieContainer being null or valid. The reason is the httpCookieContainerManager being null inside the authClient.CookieContainer property.

I am using MonoDevelop 2.4.2 on MacOS 10.6.8.
Comment 7 Sebastien Pouliot 2011-08-04 14:36:39 UTC
Rodrigo, using MT master just like me, does not get the exception. Sadly I'm not exactly sure why that happens on (a lot of build changes occurred since then). 

Please try again once MT 4.1 is released and, worse case scenario, re-open the bug report if it still occurs.