Cookies threw an exception of type System.NotImplementedException

(See UPDATE #1 below.)

All —

I am posting this here so that search engines will index it and, hopefully, someone will find it and provide an answer to this most perplexing problem.

I am using Windows 7, DotNet Framework 4, Silverlight 4, and Visual Web Developer 2010 Express.

I have a simple solution with (1) a Silverlight project front-end, (2) an ASP.NET web application project that contains the ASPX page that hosts the Silverlight front-end and it also contains an Entity datamodel and a single web-service to feed data to Silverlight.

I am getting this run-time-error (RTE)…

‘((System.Net.HttpWebResponse)(((System.Net.WebException)(((System.Exception)($exception)).InnerException)).Response)).Cookies’ threw an exception of type ‘System.NotImplementedException’

…and I am getting this RTE…

‘((System.Net.WebResponse)(((System.Net.WebException)(((System.Exception)($exception)).InnerException)).Response)).Headers’ threw an exception of type ‘System.NotImplementedException’

…but I cannot see why.

In the custom code that I wrote, I do not use Cookies or Headers at all and none of the methods that I have written are “NotImplemented”.

The web service simply returns a small string that contains XML and I am BOOM stuck.

Can you help?

Please advise.

(FYI, the error returned to the Silverlight client app is the dreaded “Not Found” error. I have seen some attempts at explaining why Silverlight shows that error and why it “must” be that way. For the life of me, I still can see no good reason for there being (apparently) no way to have “ex.ToString()” auto-propogated from the web service back to the Silverlight client, at least during debugging. That way, we give the programmer at least a chance, rather than wrapping in some meaninless “Not Found” error and (effectively) burying the exception information. Anyway, so be it. At this point, I am just trying to debug. Note that in the “Not Found” error in the Silverlight client in debug-mode in the VS IDE, it says see InnerException Response and other details and it is in the InnerException that the fateful Cookies-Not-Implemented and the like is found.)

(FYI, I have posted this on the http://www.Silverlight.net forums to no avail.)

Thank you.

— Mark Kamoski

UPDATE #1

This is an update.

To recap, as of 20110203, I was getting this RTE…

‘((System.Net.HttpWebResponse)(((System.Net.WebException)(((System.Exception ($exception)).InnerException)).Response)).Cookies’ threw an exception of type ‘System.NotImplementedException’

…and this RTE…

‘((System.Net.WebResponse)(((System.Net.WebException)(((System.Exception ($exception)).InnerException)).Response)).Headers’

threw an exception of type ‘System.NotImplementedException’

…so, after much trial and error, I changed the “web.config” file in the ASP.NET Web Application project

(which holds the “Default.aspx” hosting page for the Silverlight front-end AND which hosts the core data web service for the app)…

…changed from this…

<configuration>

<system.serviceModel>

<bindings>

<customBinding>

<binding name=”Test.Project12.Web.DataService.customBinding0″>

<binaryMessageEncoding />

<httpTransport maxReceivedMessageSize=”2147483647″ maxBufferSize=”2147483647″ />

</binding>

</customBinding>

</bindings>

</system.serviceModel>

….

</configuration>

…changed to this…

<configuration>

<system.serviceModel>

<bindings>

<customBinding>

<binding name=”Test.Project12.Web.DataService.customBinding0″>

<binaryMessageEncoding />

<httpTransport maxReceivedMessageSize=”2147483647″ maxBufferSize=”2147483647″ allowCookies=”true” />

</binding>

</customBinding>

</bindings>

</system.serviceModel>

….

</configuration>

…and now it works fine.

HTH.

Thank you.

— Mark Kamoski