Hi,
I recently updated everything in my Visual Studio Mac installation. I still use Xamarin Forms 3.1 though.
After this update, I have got a lot of crashes from Android users (I haven't released the iOS version yet) and it seems to be related to HttpWebRequest. I use it in the following way:
WebRequest req = HttpWebRequest.CreateDefault(new Uri(url)); req.Timeout = TimeoutMilis; ... using (Stream dataStream = req.GetRequestStream()) { dataStream.Write(data, 0, data.Length); }
I have a try catch around it, but it seems like these errors are not caught. The stack traces I get are not very helpful either:
android.runtime.JavaProxyThrowable: System.AggregateException: A Tasks exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.Net.WebException: The request was aborted: The request was canceled. caused.AggregateException(s) System.Net.HttpWebRequest.<MyGetResponseAsync>d__243.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0 --- End of inner exception stack trace --- ---> (Inner Exception #0) System.Net.WebException: The request was aborted: The request was canceled. System.Net.HttpWebRequest.<MyGetResponseAsync>d__243.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0
Another similar crash:
android.runtime.JavaProxyThrowable: System.AggregateException: A Tasks exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.ObjectDisposedException: Cannot access a disposed object. caused.AggregateException(s) Object name: 'System.Net.Sockets.Socket'. System.Net.Sockets.Socket.ThrowIfDisposedAndClosed()<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.Sockets.SocketTaskExtensions.<>c.<ConnectAsync>b__2_1(IAsyncResult asyncResult)<1430f9cebba746309b69090b6cda9ce8>:0 System.Threading.Tasks.TaskFactory<TResult>.FromAsyncCoreLogic(IAsyncResult iar, Func<T, TResult> endFunction, Action<T> endAction, Task<TResult> promise, bool requiresSynchronization)<e7c4dd6cd0ad467d9712102a6791959b>:0 System.Net.WebConnection.<Connect>d__16.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.WebConnection.<InitConnection>d__19.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.WebOperation.<Run>d__57.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.WebCompletionSource<T>.<WaitForCompletion>d__15.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.WebOperation.<GetRequestStream>d__49.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0 --- End of inner exception stack trace --- ---> (Inner Exception #0) System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'. System.Net.Sockets.Socket.ThrowIfDisposedAndClosed()<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.Sockets.SocketTaskExtensions.<>c.<ConnectAsync>b__2_1(IAsyncResult asyncResult)<1430f9cebba746309b69090b6cda9ce8>:0 System.Threading.Tasks.TaskFactory<TResult>.FromAsyncCoreLogic(IAsyncResult iar, Func<T, TResult> endFunction, Action<T> endAction, Task<TResult> promise, bool requiresSynchronization)<e7c4dd6cd0ad467d9712102a6791959b>:0 System.Net.WebConnection.<Connect>d__16.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.WebConnection.<InitConnection>d__19.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.WebOperation.<Run>d__57.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.WebCompletionSource<T>.<WaitForCompletion>d__15.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0 System.Net.WebOperation.<GetRequestStream>d__49.MoveNext()<1430f9cebba746309b69090b6cda9ce8>:0
Has anyone had a similar problem?