Bug 5199 - UIWindow.IsKeyWindows raises exception "[UIWindow keyWindow]: unrecognized selector sent to instance"
Summary: UIWindow.IsKeyWindows raises exception "[UIWindow keyWindow]: unrecognized se...
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
Depends on:
Reported: 2012-05-21 06:30 UTC by René Ruppert
Modified: 2012-05-22 09:16 UTC (History)
3 users (show)

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 René Ruppert 2012-05-21 06:30:54 UTC
MonoTouch 5.2.11, iPad Simulator 5, DEBUG

Accessing UIWindow's property IsKeyWindow raises an exception. Can always be reproduced. Just try accessing the property after creating your UIWindow instance in FinishedLaunching()

bjective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[UIWindow keyWindow]: unrecognized selector sent to instance 0x9bdbe40

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[UIWindow keyWindow]: unrecognized selector sent to instance 0x9c47750
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:bool_objc_msgSend (intptr,intptr)
  at MonoTouch.UIKit.UIWindow.get_IsKeyWindow () [0x0000b] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIWindow.g.cs:221 
  at BrainloopMobile.UIHelpers.ShowProtectiveView () [0x000d7] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/210/BrainloopMobile/BrainloopMobile/Helpers/UIHelpers.cs:367 
  at BrainloopMobile.AppDelegateBase.OnResignActivation (MonoTouch.UIKit.UIApplication application) [0x00037] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/210/BrainloopMobile/BrainloopMobile/AppDelegateBase.cs:835 
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr (intptr,intptr,intptr)
  at MonoTouch.UIKit.UIApplication.SendEvent (MonoTouch.UIKit.UIEvent uievent) [0x00037] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.g.cs:176 
  at BrainloopMobile.UIApplicationMain.SendEvent (MonoTouch.UIKit.UIEvent oEvent) [0x00000] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/210/BrainloopMobile/BrainloopMobile/UIApplicationMain.cs:23 
  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 BrainloopMobile.Application.Main (System.String[] args) [0x00000] in /Users/rene/Documents/Develop/Projects/BrainloopMobile/210/BrainloopMobile/BrainloopMobile/Main.cs:15 }
Comment 1 René Ruppert 2012-05-21 06:50:04 UTC

bool bIsKeyWindow = Messaging.bool_objc_msgSend(oWindow.Handle, Selector.GetHandle("isKeyWindow"));

I noticed that using "isKeyWindow:" (notice the colon) will cause the exception above.
Comment 2 Sebastien Pouliot 2012-05-22 08:22:56 UTC
Thanks. It's a typos since the property is named "keyWindow" but the getter is "isKeyWindow".
Comment 3 Sebastien Pouliot 2012-05-22 09:16:35 UTC
5.2-series: f04e32e58b526df92ace0bfcaca6d64fba0fd252
master: 80993d874f00d593a0999c2761628c0ae9f01ac7

QA: unit tests added in both branches