Bug 1225 - Error when tapping on a map location
Summary: Error when tapping on a map location
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-10-04 09:47 UTC by Alex P
Modified: 2013-12-05 18:34 UTC (History)
3 users (show)

Tags:
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:
Status:
RESOLVED NORESPONSE

Description Alex P 2011-10-04 09:47:57 UTC
My application uses a mapview to display annotations, when I tap on an annotations to see the details, I get the attached error.  



Selector invoked from objective-c on a managed object that has been GC'ed
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr klass) [0x0002e] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:200 
  at MonoTouch.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x0001f] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:244 
  at MonoTouch.ObjCRuntime.Runtime.GetNSObjectWrapped (IntPtr ptr) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:261 
  at (wrapper native-to-managed) MonoTouch.ObjCRuntime.Runtime:GetNSObjectWrapped (intptr)
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr (intptr,intptr,intptr)
  at MonoTouch.UIKit.UIWindow.SendEvent (MonoTouch.UIKit.UIEvent evt) [0x00037] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIWindow.g.cs:211 
  at apcurium.PromoApp.MT.EventUIWindow.SendEvent (MonoTouch.UIKit.UIEvent evt) [0x00000] in /sources/CXMobile/apcurium.PromoApp.MT/UIEv.cs:40 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:34 
  at apcurium.PromoApp.MT.Application.Main (System.String[] args) [0x00000] in /sources/CXMobile/apcurium.PromoApp.MT/Main.cs:36 
-------------------------------------
No constructor found for MonoTouch.UIKit.UIControlEventProxy::.ctor(System.IntPtr)
  at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x000f1] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:280 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:234 
  at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:229 
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr klass) [0x0000d] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:197 
-------------------------------------
Comment 1 Alex P 2011-10-04 09:55:08 UTC
I've reviewed my code and realize that the constructor on my MKAnnotation class were not set properly.  I added the following constructors but now I have a different error : 

	public class LocationAnnotation: MKAnnotation
	{
	
		public LocationAnnotation () : base()
		{
		}
		
		public LocationAnnotation (NSObjectFlag t) : base( t )
		{
			
		}
		
		public LocationAnnotation (IntPtr handle) : base(handle)
		{
		
		}

		[Export("initWithCoder:")]
		public LocationAnnotation (NSCoder coder) : base(coder)
		{
		
		}


Error :


2011-10-04 09:53:24.390 apcuriumPromoAppMT[3428:1207] -[NSCFString BridgeSelector]: unrecognized selector sent to instance 0xeece770
-------------------------------------
Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[NSCFString BridgeSelector]: unrecognized selector sent to instance 0xeece770
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr (intptr,intptr,intptr)
  at MonoTouch.UIKit.UIWindow.SendEvent (MonoTouch.UIKit.UIEvent evt) [0x00037] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIWindow.g.cs:211 
  at apcurium.PromoApp.MT.EventUIWindow.SendEvent (MonoTouch.UIKit.UIEvent evt) [0x00000] in /sources/CXMobile/apcurium.PromoApp.MT/UIEv.cs:40 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:34 
  at apcurium.PromoApp.MT.Application.Main (System.String[] args) [0x00000] in /sources/CXMobile/apcurium.PromoApp.MT/Main.cs:36 
-------------------------------------
Comment 2 Alex P 2011-10-04 10:04:12 UTC
I think that I found the problem but I need help to properly resolve this issue.  The problem is that the detail button that I add to the AnnotationView is being disposed by the garbage collector.

In the method 

public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation)


I get an error if I add the button like this : 
				
				UIButton rightCallout = UIButton.FromType (UIButtonType.DetailDisclosure);

				rightCallout.TouchDown += delegate { 
					 ...

				};

If I keep the button in a list then it doesn't crash but I assume the button will never be disposed by the garbage collector.  What is the best approach to fix this problem ?

Thanks.
Comment 3 Sebastien Pouliot 2011-10-04 10:54:00 UTC
This looks like a duplicate of http://bugzilla.xamarin.com/show_bug.cgi?id=631
Can you check if you keep a reference somewhere to the view being returned ?
Or attach a simple, self-contained, test case to the bug report ?
Thanks
Comment 5 PJ 2013-11-19 17:04:16 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 6 PJ 2013-12-05 18:34:18 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.