Bug 54420 - "Service not bound yet" exception in Android Service when IsolatedProcess=true
Summary: "Service not bound yet" exception in Android Service when IsolatedProcess=true
Status: RESOLVED DUPLICATE of bug 51940
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 7.1 (C9)
Hardware: PC Mac OS
: --- blocker
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2017-04-03 22:14 UTC by Dan Waters
Modified: 2017-04-14 16:06 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Simple Android service app to reproduce IsolatedProcess crash (46.42 KB, application/zip)
2017-04-03 22:14 UTC, Dan Waters

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Dan Waters 2017-04-03 22:14:41 UTC
Created attachment 21164 [details]
Simple Android service app to reproduce IsolatedProcess crash

This is a simplified, isolated version of Bug 51940 https://bugzilla.xamarin.com/show_bug.cgi?id=51940

Marking a service with IsolatedProcess=true causes the following exception when the service is started:

System.Exception: Service not bound yet
  at MyDriving.Droid.Services.GeolocationHelper.get_LocationService () [0x00015] in /Users/danwaters/MyDriving/src/MobileApps/MyDriving/MyDriving.Android/Services/GeolocationHelper.cs:31
  at MyDriving.Droid.Fragments.FragmentCurrentTrip.OnStop () [0x000c0] in /Users/danwaters/MyDriving/src/MobileApps/MyDriving/MyDriving.Android/Fragments/FragmentCurrentTrip.cs:345
  at Android.Support.V4.App.Fragment.n_OnStop (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <25036d67d6b14ac088a0cce60b36c55f>:0
  at at (wrapper dynamic-method) System.Object:14226f9d-85d2-4dff-a41b-e8319a687dd4 (intptr,intptr)

This stack trace is from the MyDriving app. https://github.com/Azure-Samples/MyDriving You can reproduce this issue in this app by setting the GeolocationService to run as an IsolatedProcess by setting IsolatedProcess=true in the [Service] attribute. 

In the attached Xamarin.Forms Android example, provided by an affected customer, the exception is not raised in the same way, but you can witness the behavior by setting IsolatedProcess in ExampleProcess.cs, line 8. 

IsolatedProcess=true results in an application crash.
IsolatedProcess=false has no effect (since the service does nothing), but does not crash the app.
Comment 1 Jonathan Pryor 2017-04-14 16:06:09 UTC
TL;DR: Things don't work when setting `ServiceAttribute.IsolatedProcess` to `true`. Same problem, different symptoms.

*** This bug has been marked as a duplicate of bug 51940 ***