Bug 872 - System.Exception: Wrapper type 'MonoTouch.UIKit.UIApplicationDelegate' is missing its native ObjectiveC class 'UIApplicationDelegate'. Please check if it's been linked.
Summary: System.Exception: Wrapper type 'MonoTouch.UIKit.UIApplicationDelegate' is mis...
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- critical
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2011-09-16 20:54 UTC by kenny goers
Modified: 2011-09-19 19:16 UTC (History)
2 users (show)

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


Attachments
Code and iOS Logs and Console Logs from Organizer (309.96 KB, application/zip)
2011-09-17 15:16 UTC, kenny goers
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 INVALID

Description kenny goers 2011-09-16 20:54:35 UTC
Attached is a stack trace for a bug I only encounter on an actual iPAD, the application runs perfectly in the emulator.  If requested I will produce code, the bug happens at start up on every instance.


Loaded assembly: /private/var/mobile/Applications/A4AF6ED5-4CB0-48B7-9D71-E3FD32463A69/ProLandscapeTouch.app/Mono.Security.dll [External]
Loaded assembly: /private/var/mobile/Applications/A4AF6ED5-4CB0-48B7-9D71-E3FD32463A69/ProLandscapeTouch.app/System.dll [External]
Loaded assembly: /private/var/mobile/Applications/A4AF6ED5-4CB0-48B7-9D71-E3FD32463A69/ProLandscapeTouch.app/monotouch.dll [External]
Loaded assembly: /private/var/mobile/Applications/A4AF6ED5-4CB0-48B7-9D71-E3FD32463A69/ProLandscapeTouch.app/System.Core.dll [External]
Loaded assembly: /private/var/mobile/Applications/A4AF6ED5-4CB0-48B7-9D71-E3FD32463A69/ProLandscapeTouch.app/MonoTouchNinePatch.dll
Loaded assembly: /private/var/mobile/Applications/A4AF6ED5-4CB0-48B7-9D71-E3FD32463A69/ProLandscapeTouch.app/MonoTouch.Dialog.dll
Loaded assembly: /private/var/mobile/Applications/A4AF6ED5-4CB0-48B7-9D71-E3FD32463A69/ProLandscapeTouch.app/MonoCrossNavigationMT.dll
Loaded assembly: /private/var/mobile/Applications/A4AF6ED5-4CB0-48B7-9D71-E3FD32463A69/ProLandscapeTouch.app/MonoCrossTouch.dll
Loaded assembly: /private/var/mobile/Applications/A4AF6ED5-4CB0-48B7-9D71-E3FD32463A69/ProLandscapeTouch.app/LandscapePro.dll
Loaded assembly: /private/var/mobile/Applications/A4AF6ED5-4CB0-48B7-9D71-E3FD32463A69/ProLandscapeTouch.app/LandscapeProTouch.exe
Thread started: Finalizer
Controller Load Begin
Thread started: 
Controller Load End
MXTouchViewGroupTabController: Render
System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.Debugging.Soft.PropertyValueReference..ctor (Mono.Debugging.Evaluation.EvaluationContext ctx, Mono.Debugger.Soft.PropertyInfoMirror property, System.Object obj, Mono.Debugger.Soft.TypeMirror declaringType, Mono.Debugger.Soft.Value[] indexerArgs) [0x00056] in /private/tmp/source/monodevelop/main/src/addins/MonoDevelop.Debugger.Soft/Mono.Debugging.Soft/PropertyValueReference.cs:52 
  at (wrapper remoting-invoke-with-check) Mono.Debugging.Soft.PropertyValueReference:.ctor (Mono.Debugging.Evaluation.EvaluationContext,Mono.Debugger.Soft.PropertyInfoMirror,object,Mono.Debugger.Soft.TypeMirror,Mono.Debugger.Soft.Value[])
  at Mono.Debugging.Soft.SoftDebuggerAdaptor.GetMember (Mono.Debugging.Evaluation.EvaluationContext ctx, System.Object t, System.Object co, System.String name) [0x000a7] in /private/tmp/source/monodevelop/main/src/addins/MonoDevelop.Debugger.Soft/Mono.Debugging.Soft/SoftDebuggerAdaptor.cs:385 
  at Mono.Debugging.Evaluation.ObjectValueAdaptor.GetMember (Mono.Debugging.Evaluation.EvaluationContext ctx, IObjectSource objectSource, System.Object t, System.Object co, System.String name) [0x00000] in /private/tmp/source/monodevelop/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ObjectValueAdaptor.cs:631 
  at Mono.Debugging.Evaluation.ObjectValueAdaptor.GetMember (Mono.Debugging.Evaluation.EvaluationContext ctx, IObjectSource objectSource, System.Object co, System.String name) [0x00000] in /private/tmp/source/monodevelop/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ObjectValueAdaptor.cs:626 
  at Mono.Debugging.Evaluation.ValueReference.GetChild (System.String name, Mono.Debugging.Client.EvaluationOptions options) [0x0009d] in /private/tmp/source/monodevelop/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/ValueReference.cs:251 
  at Mono.Debugging.Evaluation.EvaluatorVisitor.VisitMemberReferenceExpression (ICSharpCode.OldNRefactory.Ast.MemberReferenceExpression memberReferenceExpression, System.Object data) [0x00013] in /private/tmp/source/monodevelop/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryEvaluator.cs:595 
  at ICSharpCode.OldNRefactory.Ast.MemberReferenceExpression.AcceptVisitor (IAstVisitor visitor, System.Object data) [0x00000] in /private/tmp/source/monodevelop/main/contrib/NRefactory/Project/Src/Ast/Generated.cs:2840 
  at Mono.Debugging.Evaluation.NRefactoryEvaluator.Evaluate (Mono.Debugging.Evaluation.EvaluationContext ctx, System.String exp, System.Object expectedType, Boolean tryTypeOf) [0x00164] in /private/tmp/source/monodevelop/main/src/core/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryEvaluator.cs:89 
Unhandled Exception: System.Exception: Wrapper type 'MonoTouch.UIKit.UIApplicationDelegate' is missing its native ObjectiveC class 'UIApplicationDelegate'. 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.UIKit.UIApplicationDelegate..ctor () [0x00000] in <filename unknown>:0 
  at MonoCross.Touch.MGSplitViewController..ctor () [0x00000] in <filename unknown>:0 
  at MonoCross.Touch.TouchNavigation.Init (MonoTouch.UIKit.UIViewController viewController) [0x0004f] in /Users/mac/Projects/monocross-beanstalk/MonoCross.Touch/TouchNavigation.cs:99 
  at MonoCross.Touch.TouchNavigation.PushToViewGroup (MonoCross.Touch.MXTouchViewGroup viewGroup, MonoCross.Touch.MXTouchViewGroupItem viewGroupItem, MonoTouch.UIKit.UIViewController viewController) [0x00060] in /Users/mac/Projects/monocross-beanstalk/MonoCross.Touch/TouchNavigation.cs:155 
  at MonoCross.Touch.MXTouchContainer.LoadViewForController (IMXView fromView, IMXController controller, MonoCross.Navigation.MXViewPerspective viewPerspective) [0x0016a] in /Users/mac/Projects/monocross-beanstalk/MonoCross.Touch/MXTouchContainer.cs:255 
  at MonoCross.Touch.MXTouchContainer+<OnControllerLoadComplete>c__AnonStorey0.<>m__0 () [0x00000] in /Users/mac/Projects/monocross-beanstalk/MonoCross.Touch/MXTouchContainer.cs:135 
  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 Touch.Container.Application.Main (System.String[] args) [0x00000] in /Users/mac/Projects/IDP/ProLandscape.Touch/Main.cs:20 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: Wrapper type 'MonoTouch.UIKit.UIApplicationDelegate' is missing its native ObjectiveC class 'UIApplicationDelegate'. 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.UIKit.UIApplicationDelegate..ctor () [0x00000] in <filename unknown>:0 
  at MonoCross.Touch.MGSplitViewController..ctor () [0x00000] in <filename unknown>:0 
  at MonoCross.Touch.TouchNavigation.Init (MonoTouch.UIKit.UIViewController viewController) [0x0004f] in /Users/mac/Projects/monocross-beanstalk/MonoCross.Touch/TouchNavigation.cs:99 
  at MonoCross.Touch.TouchNavigation.PushToViewGroup (MonoCross.Touch.MXTouchViewGroup viewGroup, MonoCross.Touch.MXTouchViewGroupItem viewGroupItem, MonoTouch.UIKit.UIViewController viewController) [0x00060] in /Users/mac/Projects/monocross-beanstalk/MonoCross.Touch/TouchNavigation.cs:155 
  at MonoCross.Touch.MXTouchContainer.LoadViewForController (IMXView fromView, IMXController controller, MonoCross.Navigation.MXViewPerspective viewPerspective) [0x0016a] in /Users/mac/Projects/monocross-beanstalk/MonoCross.Touch/MXTouchContainer.cs:255 
  at MonoCross.Touch.MXTouchContainer+<OnControllerLoadComplete>c__AnonStorey0.<>m__0 () [0x00000] in /Users/mac/Projects/monocross-beanstalk/MonoCross.Touch/MXTouchContainer.cs:135 
  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 Touch.Container.Application.Main (System.String[] args) [0x00000] in /Users/mac/Projects/IDP/ProLandscape.Touch/Main.cs:20 
Terminating runtime due to unhandled exception
Stacktrace:


Native stacktrace:

	0   LandscapeProTouch                   0x003805e4 mono_handle_native_sigsegv + 412
	1   LandscapeProTouch                   0x003a850c sigabrt_signal_handler + 148
	2   libsystem_c.dylib                   0x3260572f _sigtramp + 42
	3   libsystem_c.dylib                   0x325fa3bb pthread_kill + 58
	4   libsystem_c.dylib                   0x325f2bff abort + 78
	5   LandscapeProTouch                   0x004c0b5c monoeg_g_logv + 248
	6   LandscapeProTouch                   0x004c0bf0 monoeg_assertion_message + 44
	7   LandscapeProTouch                   0x00361f04 mono_thread_abort + 224
	8   LandscapeProTouch                   0x0037f984 mono_handle_exception_internal + 2436
	9   LandscapeProTouch                   0x0038026c mono_handle_exception + 108
	10  LandscapeProTouch                   0x003a6510 mono_arm_throw_exception + 324
	11  LandscapeProTouch                   0x0027a5ac throw_exception + 48
	12  LandscapeProTouch                   0x00071e80 MonoTouch_ObjCRuntime_Class_GetHandle_System_Type + 312
	13  LandscapeProTouch                   0x0006fc14 MonoTouch_Foundation_NSObject_AllocIfNeeded + 92
	14  LandscapeProTouch                   0x0006f5ac MonoTouch_Foundation_NSObject__ctor_MonoTouch_Foundation_NSObjectFlag + 32
	15  LandscapeProTouch                   0x00077e30 MonoTouch_UIKit_UIApplicationDelegate__ctor + 44
	16  LandscapeProTouch                   0x000ee150 MonoCross_Touch_MGSplitViewController__ctor + 732
	17  LandscapeProTouch                   0x00101250 MonoCross_Touch_TouchNavigation_Init_MonoTouch_UIKit_UIViewController + 568
	18  LandscapeProTouch                   0x00101ab8 MonoCross_Touch_TouchNavigation_PushToViewGroup_MonoCross_Touch_MXTouchViewGroup_MonoCross_Touch_MXTouchViewGroupItem_MonoTouch_UIKit_UIViewController + 892
	19  LandscapeProTouch                   0x000fb888 MonoCross_Touch_MXTouchContainer_LoadViewForController_MonoCross_Navigation_IMXView_MonoCross_Navigation_IMXController_MonoCross_Navigation_MXViewPerspective + 3248
	20  LandscapeProTouch                   0x000fbe34 MonoCross_Touch_MXTouchContainer__OnControllerLoadCompletec__AnonStorey0__m__0 + 156
	21  LandscapeProTouch                   0x0006b4d0 MonoTouch_Foundation_NSActionDispatcher_Apply + 44
	22  LandscapeProTouch                   0x00243130 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
	23  LandscapeProTouch                   0x00365fbc mono_jit_runtime_invoke + 2800
	24  LandscapeProTouch                   0x00456054 mono_runtime_invoke + 140
	25  LandscapeProTouch                   0x004df32c monotouch_trampoline + 2840
	26  CoreFoundation                      0x32941f03 -[NSObject(NSObject) performSelector:withObject:] + 22
	27  Foundation                          0x373827a9 __NSThreadPerformPerform + 268
	28  CoreFoundation                      0x329aba79 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
	29  CoreFoundation                      0x329ad6a3 __CFRunLoopDoSources0 + 194
	30  CoreFoundation                      0x329ae4eb __CFRunLoopRun + 230
	31  CoreFoundation                      0x3293eec3 CFRunLoopRunSpecific + 230
	32  CoreFoundation                      0x3293edcb CFRunLoopRunInMode + 58
	33  GraphicsServices                    0x3693c41f GSEventRunModal + 114
	34  GraphicsServices                    0x3693c4cb GSEventRun + 62
	35  UIKit                               0x35765d69 -[UIApplication _run] + 404
	36  UIKit                               0x35763807 UIApplicationMain + 670
	37  LandscapeProTouch                   0x000a9594 wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 240
	38  LandscapeProTouch                   0x00063e60 Touch_Container_Application_Main_string__ + 152
	39  LandscapeProTouch                   0x00243130 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
	40  LandscapeProTouch                   0x00365fbc mono_jit_runtime_invoke + 2800
	41  LandscapeProTouch                   0x00456054 mono_runtime_invoke + 140
	42  LandscapeProTouch                   0x00459010 mono_runtime_exec_main + 784
	43  LandscapeProTouch                   0x0045806c mono_runtime_run_main + 1048
	44  LandscapeProTouch                   0x0036d7a8 mono_jit_exec + 216
	45  LandscapeProTouch                   0x00360758 main + 5044
	46  LandscapeProTouch                   0x000027f4 start + 52

Debug info from gdb:


=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
Comment 1 Sebastien Pouliot 2011-09-17 10:55:24 UTC
It could be a managed linker issue. Can you try building your device application with "Don't link" ? [1] which is the same setting that is used, by default, for the simulator builds. 

That will tell us if the issue is related to the linker or not. However we'll likely need a test case to duplicate the issue (linker or not) and know which version of MonoTouch you're presently using [2]. Thanks!

[1] right click on your main project, select "Options", select "iPhone Build" and change the "Linker behavior" combobox value
[2] run "/Developer/MonoTouch/usr/bin/mtouch --version" in a terminal window
Comment 2 kenny goers 2011-09-17 15:16:15 UTC
Created attachment 413 [details]
Code and iOS Logs and Console Logs from Organizer

Here lies all the code to reproduce the bug, it happens on start up, just the the program and it crashs.  It only crashes on the device itself, never in the simulator.

Note!  

Linking I get the reported error, when NOT linking, I still get an error, but different, logs for both are in the root of the code directory in the ZIP file.

Please let me know when a fix might be available, this is an issue for me, if I need to go back to an earlier version, please provide instructions for that.

Thanks!
Kenny.
Comment 3 Sebastien Pouliot 2011-09-19 16:59:17 UTC
It's not clear to me why MGSplitViewController.cs is creating a new instance of UIApplicationDelegate ? I could be wrong but I assumed this was not possible (to have more than one inside a single app).

		//private MGSplitViewAppDelegate splitViewDelegate = new MGSplitViewAppDelegate();
		private UIApplicationDelegate _splitViewDelegate = new UIApplicationDelegate();

note: the error when not linking look like another case of #587.
Comment 4 Sebastien Pouliot 2011-09-19 19:16:51 UTC
received from email:

> It's a bunch of code converted from Objective C, I removed the
> allocation of the UIApplicationDelegate and now it works perfectly
> when LINKED.  I still have the other bug (the LINQ query) when it is
> not linked.  You can mark the first part as resolved, although I never
> would have guessed that as an issue...
> 
> Thanks!

I'm closing this bug as invalid and I'll annotate bug #587 (no link issue) wrt this one too. Thanks a lot for providing the test case!

note: you should always link your device application (at least "Link SDK assemblies") to minimize their size (for end users) and also to get faster build times (linking time is generally a lot smaller than the AOT time it saves).