Bug 769 - [regression 4.0.5] Wrapper type 'MonoTouch.MapKit.MKMapViewDelegate' is missing its native ObjectiveC class 'MKMapViewDelegate'.
Summary: [regression 4.0.5] Wrapper type 'MonoTouch.MapKit.MKMapViewDelegate' is missi...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 4.x
Hardware: Other Other
: --- blocker
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2011-09-12 21:04 UTC by dj_technohead
Modified: 2011-10-04 13:29 UTC (History)
3 users (show)

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


Attachments
test app that shows this error (4.12 MB, application/x-zip-compressed)
2011-10-01 21:25 UTC, dj_technohead
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 dj_technohead 2011-09-12 21:04:20 UTC
This exception appeared after installing MonoTouch 4.0.6 and exists in 4.0.7. I reinstalled MT 4.0.5 and the exception is not raised. The exception message and stacktrace is as follows:

Wrapper type 'MonoTouch.MapKit.MKMapViewDelegate' is missing its native ObjectiveC class 'MKMapViewDelegate'. Please check if it's been linked. - :: at MonoTouch.ObjCRuntime.Class.Register (System.Type type, System.String name, Boolean is_wrapper) [0x00000] in <filename unknown>:0
at MonoTouch.ObjCRuntime.Class.GetHandle (System.Type type) [0x00000] in <filename unknown>:0
at MonoTouch.Foundation.NSObject.AllocIfNeeded () [0x00000] in <filename unknown>:0
at MonoTouch.Foundation.NSObject..ctor (MonoTouch.Foundation.NSObjectFlag x) [0x00000] in <filename unknown>:0
at MonoTouch.MapKit.MKMapViewDelegate..ctor () [0x00000] in <filename unknown>:0
at Locator.iPhonePersonalMenuMapViewController.ViewDidLoad () [0x000ac] in /Users/technohead/Projects/Locator/Locator/iPhone/PersonalMenu/iPhonePersonalMenuMapViewController.xib.cs:63
at MonoTouch.UIKit.UIViewController.get_View () [0x00000] in <filename unknown>:0
at Locator.iPhonePersonalMenuViewController.ViewDidLoad () [0x000af] in /Users/technohead/Projects/Locator/Locator/iPhone/PersonalMenu/iPhonePersonalMenuViewController.xib.cs:68
at MonoTouch.UIKit.UINavigationController.PushViewController (MonoTouch.UIKit.UIViewController viewController, Boolean animated) [0x00000] in <filename unknown>:0
at Locator.AppDelegateIPhone.PushView (MonoTouch.UIKit.UIViewController viewController) [0x00000] in /Users/technohead/Projects/Locator/Locator/iPhone/AppDelegateIPhone.cs:138
at Locator.iPhoneSearchViewController+<handleProductsTableViewSourceOnRowSelected>c__AnonStorey2.<>m__11 () [0x0001f] in /Users/technohead/Projects/Locator/Locator/iPhone/iPhoneSearchViewController.xib.cs:563
at MonoTouch.Foundation.NSActionDispatcher.Apply () [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in <filename unknown>:0
at Locator.Application.Main (System.String[] args) [0x00000] in /Users/technohead/Projects/Locator/Locator/Main.cs:19 


Line 63 in iPhonePersonalMenuMapViewController.xib.cs appears as follows:

this.mapView.Delegate = new MKMapViewDelegate();
Comment 1 Sebastien Pouliot 2011-09-13 11:20:56 UTC
Does it happen only on the simulator, the device or both ?

Can you try rebuilding using "Don't link" on the case where it fails ?

and try "Link SDK assemblies" if it works (e.g. on the simulator) ?

Finally can you provide us with a small, self-contained, test case ?

Thanks
Sebastien
Comment 2 dj_technohead 2011-09-13 18:14:55 UTC
I think the problem was caused by an install that did not complete successfully. I tried rolling forward to 4.0.6 and then 4.0.7 but am not able to reproduce the error with the same code. I've seen issues with the install process a number of times, typically after installing MT, when relaunching MD, it can not find MT, and I have to install MT one or more times in order for it to work. This is the first time, that an install appears to have worked but manifested an error at run time.
Comment 3 Sebastien Pouliot 2011-09-13 19:11:37 UTC
It's the first time I heard about such installation issue. Please fill a bug report the next time this occurs so we can track this and, hopefully, find and fix it.

Also be sure to re-open the bug if you can duplicate again this issue (in case it was not installation related). Thanks!
Comment 4 dj_technohead 2011-09-21 22:19:17 UTC
Sorry, I think I got confused with the different version of MonoTouch that I have running on my computers. Is there a way to view what version of MT I am currently running?

I have just downloaded MT 4.2.1, cleaned the solution and rebuilt and then rerun and am getting this error again. This error only occurs on the physical device.

I tried rebuilding with "Don't Link" but it failed upon starting the app with the error: "Attempting to JIT compile method 'System.Linq.Enumerable:ToArray (System.Collections.Generic.IEnumerable`1)' while running with --aot-only."

I tried all three build options, rebuilt the application, and none worked. 

I am trying to build a test project but am not able to get a running copy on the physical iphone. Is there a way to deploy to the physical device without having a provisioning profile for the app? I'm currently getting the error: This application has been signed with a provisioning profile which does not include this device
Installation failed: AMDeviceInstallApplication returned: 0xe8000050. The developer identity is set to "Developer (Automatic)" and the provisioning profile is set to "Automatic".
Comment 5 Sebastien Pouliot 2011-09-22 08:06:02 UTC
> Is there a way to view what version of MT I am currently running?

run "/Developer/MonoTouch/usr/bin/mtouch --version" from a terminal window

> I have just downloaded MT 4.2.1, cleaned the solution and rebuilt and then
> rerun and am getting this error again.

Please attach a test case so we can reproduce the issue

> I tried rebuilding with "Don't Link" but it failed

This was bug #587, it was fixed after the release of MonoTouch 4.2.1. However it should not concern you as there's no real situation (beside testing the linker) where you should use "Don't link" for application built for devices (linking gives you smaller applications and faster AOT times to build them).

> I tried all three build options, rebuilt the application, and none worked. 

Ok, it does not totally remove the linker from the suspect list (since it fails for a different reason) but we'll be able to chekc this with a test case.

> I'm currently getting the error:
> This application has been signed with a provisioning profile which does not
> include this device

If you use the same profiles and the same hardware between your main application and your test project then you should not have any issue. This error message tells you that the device does not have a certificate/profile that match the one that was used to build your application.
Comment 6 dj_technohead 2011-10-01 21:25:34 UTC
Created attachment 552 [details]
test app that shows this error

This crash occurs with MT 4.2.1 and 4.2.2 and only on the physical device. Run the app and you will see a button on a mapview. Pressing the button will cause an instance of MKMapViewDelegate to be created and assigned to the mapview's delegate property.
Comment 7 Sebastien Pouliot 2011-10-02 13:20:46 UTC
got it, thanks for the sample
Comment 8 Sebastien Pouliot 2011-10-02 13:55:24 UTC
* It's not linker related - likely that the same error message can (or could) be reached with other condition(s).

* This specific exception is only thrown on devices (since the simulator registration code if fairly different, for many reasons - e.g. to enable faster build time registration occurs at runtime, not compile time). That part of code likely changed a bit from older 4.0.x releases and it's likely why you're seeing the exception. I'll look into it (to see what changed and why).

* I'm not sure about using "directly" MKMapViewDelegate - the default implementation does nothing (but throwing exception in every method, except the constructors). It's goal is to be overridden to provide to customize a MapView. Personally I don't recall using a *Delegate type without inheriting and overriding stuff from them (makes me wonder why they are not abstract, maybe some of them are more usable "as-is" as others).

* Defining your own *Delegate works (i.e. it's registered properly to be used). E.g.

	class MyMKMapViewDelegate : MKMapViewDelegate {
	}


		void HandleBtnTesthandleTouchUpInside (object sender, EventArgs e)
		{
			this.mkMapViewDelegate = new MyMKMapViewDelegate ();
			this.mapView.Delegate = this.mkMapViewDelegate;
		}

Of course it will still throw (You_Should_Not_Call_base_In_This_Method) on every method but it won't crash your application anymore. Please see this as a "workaround" until I track down why this behavior changed and confirm me if this "unblocks" you. Thanks
Comment 10 Sebastien Pouliot 2011-10-03 11:55:05 UTC
Device registration code skip types decorated with [Model] but the registration code change in 4.0.6+ does not check that. Testing fix...
Comment 11 dj_technohead 2011-10-04 03:21:31 UTC
Thanks, that fixed it. I think that those delegate classes ought to be marked as abstract to prevent this. To be honest, I wasn't sure why I did that, probably left that as a placeholder, but since it was working in 4.0.7, I didn't think that that would have been the cause of the exception.
Comment 12 Sebastien Pouliot 2011-10-04 13:29:20 UTC
Thanks for the confirmation.
Fixed in daf0d5730fbe93712cc44e96cc491748a7e46e97 (master)