Bug 56424 - RegistrationListener.UnregisterFromRuntime throws System.NotSupportedException
Summary: RegistrationListener.UnregisterFromRuntime throws System.NotSupportedException
Alias: None
Product: Android
Classification: Xamarin
Component: Android+BCL Integration ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Habersack
Depends on:
Reported: 2017-05-14 10:43 UTC by Sevket Kizanlik
Modified: 2017-06-27 17:11 UTC (History)
2 users (show)

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

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 Sevket Kizanlik 2017-05-14 10:43:18 UTC

Registration listener class:
using Android.Net.Sip;
using Android.Runtime;
using System;

namespace Com.Acme.Android.Service.Listener {

    public class Registration : Java.Lang.Object, ISipRegistrationListener {

        public Registration () { }

        //public Registration (IntPtr a, JniHandleOwnership b) { }

	public void OnRegistering (String localProfileUri) { }
	public void OnRegistrationDone (String localProfileUri, Int64 expiryTime) { }
	public void OnRegistrationFailed (String localProfileUri, [GeneratedEnum] SipErrorCodes errorCode, String errorMessage) { }



When a device tries to register to the service provider, OnRegistrationFailed event always fires. Then OnRegistering and OnRegistrationDone events fire twice but in random order like this:

OnRegistrationFailed -> OnRegistering -> OnRegistering -> OnRegistrationDone -> OnRegistrationDone
OnRegistrationFailed -> OnRegistering -> OnRegistrationDone -> OnRegistering -> OnRegistrationDone

After registration is done, device is able to make / receive calls interestingly. If the device tries to unregister from the service provider by ("Manager" is an instance of "SipManager")

Manager.Unregister (SipProfileLocal, registrationListener);

method, this method doesn't have any effect on the service provider. The device seems to be still registered. I tried to unregister the registration listener by

registrationListener.UnregisterFromRuntime ();

method before unregister the device from the service provider but this exception occured.

Exception caught:
Unable to activate instance of type Com.Acme.Android.Service.Listener.Registration from native handle 0x2a800001 (key_handle 0x41d3db50).

{System.MissingMethodException: No constructor found for Com.Acme.Android.Service.Listener.Registration::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <33e6e739ac344166b157e323586f11a1>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <33e6e739ac344166b157e323586f11a1>:0 }
Comment 1 Mark McLemore 2017-06-23 21:22:26 UTC
Thank you for taking the time to submit the bug. We are unable to reproduce this issue. Please attach a reproduction to the bug by starting with a clean Xamarin.Android project and adding just the code necessary to demonstrate the issue.
Comment 2 Sevket Kizanlik 2017-06-27 12:46:41 UTC
Dear Mark,

I tried to reproduce the issue but yes, it is not reproducible. While I was trying to reproduce it, I recalled that Xamarin Android received a hotfix at that time, v7.3.1.2. The hotfix fixed the issue. This is just for your information.
Comment 3 Mark McLemore 2017-06-27 17:11:16 UTC
Hi Sevket,

Thanks for letting us know!