Unhandled Exception in Airplane Mode

0 votes

Hi,

 

I'm currently working on a Xamarin Forms app for iOS (published)/Android (published)/WinRT (soon to be published) using the App42 SDK for Xamarin2.0.
 
When testing on an iPhone 6S (iOS 10) or on a Moto X (Android M) in airplane mode, I get an unhandled exception from the App42 library that leads to a fatal crash of the app, which is definitely a show stopper. From the stacktrace, you can see that it is thrown from a thread that is owned by App42's library, over which I have no control. AFAIK, I can't catch and handle that exception.
 
A possible workaround would be to test for connectivity before calling any of App42's methods, but that exception (or a different one?) might still be thown if, for example, connectivity is lost between the test and the effective call... Best practice tells us to catch the exception on App42's side and pass it around through the error callback of the FindAllDocuments method.
 
Any idea how to remedy to the situation?
 
The Xamarin SDK I'm using (2.0) seems to be quite old (december 2015), is there a more recent/stable version around?
 
You'll find the details of the exception below.
 
--------------------------------------------------------------------------------------------------
 
Unhandled Exception:
System.Net.WebException: Error: NameResolutionFailure
  at com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorAsync.ExecuteGet (System.String url, System.Collections.Generic.Dictionary`2[TKey,TValue] paramsDics, System.Collections.Generic.Dictionary`2[TKey,TValue] headerParams) [0x000fa] in <e5033534dee042a4a22cdb500c3247c1>:0 
  at com.shephertz.app42.paas.sdk.csharp.storage.StorageService.FindAllDocuments (System.String dbName, System.String collectionName) [0x000c4] in <e5033534dee042a4a22cdb500c3247c1>:0 
  at com.shephertz.app42.paas.sdk.csharp.storage.StorageService+<>c__DisplayClass7.<FindAllDocuments>b__6 () [0x00000] in <e5033534dee042a4a22cdb500c3247c1>:0 
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00017] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/threading/thread.cs:68 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x0008d] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:957 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:904 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00031] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:893 
  at System.Threading.ThreadHelper.ThreadStart () [0x0000b] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/threading/thread.cs:105 
 
--------------------------------------------------------------------------------------------------
 
Best regards,
Jonathan
asked Nov 26, 2016 in Xamarin by jonathan.derrough (10 points)

1 Answer

0 votes
Hi, I have the similar (or same?) issue, using c# version and xamarin. The app42 library send a timeout error.

I used try/catch  to handle it
answered Nov 28, 2016 by gamonsoftware (10 points)
Hi,

I use a try/catch block too:

try
{
    storageService.FindAllDocuments(BackendManager.DbName, CategoriesCollectionName, new App42ShopsCallback(App42FindAllDocuments_OnSuccess, App42FindAllDocuments_OnException));
}
catch (Exception e)
{
    Debug.WriteLine("GetCategories exception: {0}", e.Message);
}

But if you look at the stack trace in my original post, the exception is not thrown in the calling thread but in a thread created by App42's library which makes it impossible to be caught on my side, ending in a crash.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...