views:

79

answers:

1

The following line of code throws an ArgumentNullException under Chrome and Firefox in silverlight. I am using HttpWebRequest to post a file to the server. The exception doesn't happen in IE and only happens when I am uploading a larger file (5mb). Under IE it works just fine. I didn't see any reason in the documentation why the code would throw this exception.

//note that asyncResult is not null
response = (HttpWebResponse)request.EndGetResponse(asyncResult);

Here is the stack trace from the exception and inner exception:

at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)\r\n at System.Net.Browser.ClientHttpWebRequest.<>c_DisplayClass5.b_4(Object sendState)\r\n at System.Net.Browser.AsyncHelper.<>c_DisplayClass2.b_0(Object sendState)"

" at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)\r\n at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\r\n at DC.FileUpload.FileUpload.<>c_DisplayClassc.b_a(IAsyncResult asyncResult)"

A: 

I got exactly same weird error with HttpWebResponse (but in absolutely other circumstances) few days ago. In my case it was multithreading problem. Looks like main thread and one of working threads (with delegate) tries to share some variable. So I may suggest you try to move all class level variables into methods bodies (or add locking for critical sections) and then debug your application with active "Threads" window.
To enable this window click Debug=>Windows=>Threads during debugging. I hope it helps you in struggle with that weird error.

zenonych