[MonoTouch] 100% NullReferenceException in HttpWebRequest.GetRequestStream()

Nic Wise nicw at fastchicken.co.nz
Mon Oct 10 14:44:59 EDT 2011


Damn, glad I saw this. I just released an update which supports 3.x
with 4.2.2, and uses webclient (which uses webrequest under the hood I
think)

Pulled from the store and an update issued which is 4.0 only. It was
"waiting for review", so no big deal :)

On Mon, Oct 10, 2011 at 16:20, Jeff Stedfast <jeff at xamarin.com> wrote:
> Hi Robert,
>
> I've already fixed this bug and it will be included in MonoTouch
> 4.2.3. When I wrote the proxy support code for MonoTouch 4.2.0, I had
> missed the fact that kCFProxyTypeAutoConfigurationJavaScript was only
> available in iOS 4.0 and later (all the other proxy constants are
> defined for 2.0 and above).
>
> My apologies for this bug!
>
> Jeff
>
> On Sun, Oct 9, 2011 at 3:40 PM, Will Stones <will.stones at gmail.com> wrote:
>> Hi,
>>
>> Since upgrading to MonoTouch 4.2.2 and MonoDevelop 2.8 I'm experience a 100%
>> NullReferenceException when making a call to
>> HttpWebRequest.GetRequestStream() when running on an iOS 3.1.3 device.  I've
>> pasted the exception trace below.
>>
>> The code which reproduces the exception is as follows:
>>    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
>>    request.UserAgent = "MyUserAgent";
>>    request.Timeout = 15000;
>>    request.KeepAlive = true;
>>    request.Method = "POST";
>>    string requestString = GetQueryString();
>>    byte[] postBytes = Encoding.ASCII.GetBytes(requestString);
>>    request.ContentLength = postBytes.Length;
>>    request.ContentType = "application/x-www-form-urlencoded";
>>    // Crashes on this line
>>    request.GetRequestStream().Write(postBytes, 0, postBytes.Length);
>>
>>
>> The code used to work fine until I upgraded MT and MD (I'm afraid I've lost
>> the installers for the versions I was using so I can't tell you when the
>> problem was introduced).
>>
>> This issue is pretty critical for me...!  Can anyone confirm how long a fix
>> for an issue like this is likely to take?  If you'd like any more info on
>> this please let me know.
>>
>> Will
>>
>> [0xe374][219] <Notice>: Failed to make API call:
>> System.NullReferenceException: Object reference not set to an instance of an
>> object
>> [0xe374][219] <Notice>:   at
>> MonoTouch.CoreFoundation.CFProxy.CFProxyTypeToEnum
>> (MonoTouch.Foundation.NSString type) [0x00000] in <filename unknown>:0
>> [0xe374][219] <Notice>:   at MonoTouch.CoreFoundation.CFProxy.get_ProxyType
>> () [0x00000] in <filename unknown>:0
>> [0xe374][219] <Notice>:   at
>> MonoTouch.CoreFoundation.CFNetwork+CFWebProxy.GetProxy (System.Uri
>> targetUri) [0x00000] in <filename unknown>:0
>> [0xe374][219] <Notice>:   at
>> MonoTouch.CoreFoundation.CFNetwork+CFWebProxy.IsBypassed (System.Uri
>> targetUri) [0x00000] in <filename unknown>:0
>> [0xe374][219] <Notice>:   at System.Net.ServicePointManager.FindServicePoint
>> (System.Uri address, IWebProxy proxy) [0x00000] in <filename unknown>:0
>> [0xe374][219] <Notice>:   at System.Net.HttpWebRequest.GetServicePoint ()
>> [0x00000] in <filename unknown>:0
>> [0xe374][219] <Notice>:   at System.Net.HttpWebRequest.BeginGetRequestStream
>> (System.AsyncCallback callback, System.Object state) [0x00000] in <filename
>> unknown>:0
>> [0xe374][219] <Notice>:   at System.Net.HttpWebRequest.GetRequestStream ()
>> [0x00000] in <filename unknown>:0
>>
>>
>> --
>> View this message in context: http://monotouch.2284126.n4.nabble.com/100-NullReferenceException-in-HttpWebRequest-GetRequestStream-tp3888273p3888273.html
>> Sent from the MonoTouch mailing list archive at Nabble.com.
>> _______________________________________________
>> MonoTouch mailing list
>> MonoTouch at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/monotouch
>>
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>



-- 
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/

Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2


More information about the MonoTouch mailing list