Bug 29005 - System.InvalidOperationException when TapGestureRecognizer.Tapped is used to navigate to a ContentPage with a Map
Summary: System.InvalidOperationException when TapGestureRecognizer.Tapped is used to ...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 1.4.1
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-04-10 23:17 UTC by Jon Goldberger [MSFT]
Modified: 2015-07-15 13:33 UTC (History)
2 users (show)

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


Attachments
Test Project (530.55 KB, application/zip)
2015-04-10 23:17 UTC, Jon Goldberger [MSFT]
Details


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 FIXED

Description Jon Goldberger [MSFT] 2015-04-10 23:17:27 UTC
Created attachment 10725 [details]
Test Project

## Description

First, this issue is only occurring when on the current Alpha channel of XI version 8.10.0.197 (full version info below). This did not occur with XI 8.9 on the current Stable/Beta channel. 

When navigating to a ContentPage with a Map in a TapGesturerecognizer, the below exception (## Exception) is thrown. IN the test project, the TapGestuRerecognizer is attached to an Image, but the same occurs if attached to a Label. 

## Steps to reproduce 

1. Update Xamarin Studio to the Alpha channel with above noted versions.

2. Open the attached test project and restore packages.

3. Launch to iOS device or simulator.

4. Click on the image. 

Expected result: Will navigate to a ContentPage with a Map.

Actual Result: Exception below is thrown. 

## Notes

iOS Only. Same occurs whether Map is in a Xaml page or a page created in code. Also it does not matter if you use PushAsync() or PushModalAsync()  (using PushAsync in the test project).


## Exception

>System.InvalidOperationException: Event registration is overwriting existing delegate. Either just use events or your own delegate: Xamarin.Forms.Maps.iOS.MapDelegate MapKit.MKMapView+_MKMapViewDelegate
>  at UIKit.UIApplication.EnsureEventAndDelegateAreNotMismatched (System.Object del, System.Type expectedType) [0x0001b] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/maccore/src/UIKit/UIApplication.cs:77
>  at MapKit.MKMapView.EnsureMKMapViewDelegate () [0x0000b] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/maccore/src/build/ios/native/MapKit/MKMapView.g.cs:1580
>  at MapKit.MKMapView.add_RegionChanged (System.EventHandler`1 value) [0x00000] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/maccore/src/build/ios/native/MapKit/MKMapView.g.cs:1939
>  at Xamarin.Forms.Maps.iOS.MapRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1 e) [0x0008b] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[Xamarin.Forms.View].SetElement (Xamarin.Forms.View element) [0x00135] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[Xamarin.Forms.View].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x0001c] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x00010] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001f] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[Xamarin.Forms.VisualElement].SetElement (Xamarin.Forms.VisualElement element) [0x000e2] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[Xamarin.Forms.VisualElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x0001c] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x00010] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001f] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0007b] in <filename unknown>:0
>  at at (wrapper managed-to-native) ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
>  at UIKit.UIViewController.get_View () [0x00030] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/maccore/src/build/ios/native/UIKit/UIViewController.g.cs:2482
>  at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00008] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00024] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x0001c] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.NavigationRenderer.CreateViewControllerForPage (Xamarin.Forms.Page page) [0x00025] in <filename unknown>:0
>  at Xamarin.Forms.Platform.iOS.NavigationRenderer+<OnPushAsync>d__1c.MoveNext () [0x0000d] in <filename unknown>:0
>  at --- End of stack trace from previous location where exception was thrown ---
>  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
>  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201
>  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
>  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
>  at System.Runtime.CompilerServices.TaskAwaiter`1[System.Boolean].GetResult () [0x00000] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:372
>  at Xamarin.Forms.NavigationPage+<PushAsyncInner>d__16.MoveNext () [0x000f0] in <filename unknown>:0
>  at --- End of stack trace from previous location where exception was thrown ---
>  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
>  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201
>  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
>  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
>  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:124
>  at Xamarin.Forms.NavigationPage+<PushAsync>d__11.MoveNext () [0x001de] in <filename unknown>:0
>  at --- End of stack trace from previous location where exception was thrown ---
>  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
>  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201
>  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
>  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
>  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:124
>  at PlaygroundFormsNewPortable.DemoPage+<DemoPage>c__async0.MoveNext () [0x00022] in /Users/apple/Downloads/Playground-FormsNewPortable/Playground-FormsNewPortable/Playground-FormsNewPortable.cs:45
>  at --- End of stack trace from previous location where exception was thrown ---
>  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
>  at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1006
>  at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/maccore/src/UIKit/UIKitSynchronizationContext.cs:24
>  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/maccore/src/Foundation/NSAction.cs:164
>  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
>  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/maccore/src/UIKit/UIApplication.cs:63
>  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/macios-mac-macios-cycle5/4dac6bff/source/maccore/src/UIKit/UIApplication.cs:47
>  at PlaygroundFormsNewPortable.iOS.Application.Main (System.String[] args) [0x00008] in /Users/apple/Downloads/Playground-FormsNewPortable/iOS/Main.cs:17
>


## My environment:

=== Xamarin Studio ===

Version 5.9 (build 388)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Runtime:
	Mono 4.0.0 ((detached/21d849b)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000121

=== Xamarin.Android ===

Version: 5.1.0.100 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.iOS ===

Version: 8.10.0.197 (Business Edition)
Hash: 4dac6bf
Branch: master
Build date: 2015-04-01 21:55:11-0400

=== Xamarin.Mac ===

Version: 2.0.0.197 (Business Edition)

=== Build Information ===

Release ID: 509000388
Git revision: 027c5efa6f92249fd2e614535965159c0a7c0fe6
Build date: 2015-04-01 19:12:53-04
Xamarin addins: a6779639267bbe31df3fd6958be4ecae82665b7e

=== Operating System ===

Mac OS X 10.10.3
Darwin Jons-iMac.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 2 jpbugzilla 2015-05-05 12:25:52 UTC
I have this same issue.
Comment 4 Michael 2015-05-22 14:15:25 UTC
I have verified that this is working with Xamarin.Forms 1.4.2.
Clicking on the image successfully navigates to the map page.