[Mono-bugs] [Bug 567193] New: Crash when casting AppDelegate.window to an object of an inherited UIWindow class

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Dec 24 05:37:03 EST 2009



           Summary: Crash when casting AppDelegate.window to an object of
                    an inherited UIWindow class
    Classification: Mono
           Product: MonoTouch
           Version: unspecified
          Platform: Macintosh
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: Class Libraries
        AssignedTo: gnorton at novell.com
        ReportedBy: taxi4alex at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

Created an attachment (id=334206)
 --> (http://bugzilla.novell.com/attachment.cgi?id=334206)
Sample project for the issue.

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;
rv: Gecko/20091201 Firefox/3.5.6

The application was crashed when trying to cast a UIWindow object to an object
inherited from UIWindow class with the exception:

Unhandled Exception: System.InvalidCastException: Cannot cast from source type
to destination type.
  at MyWebView.BrowserViewController.ViewDidLoad () [0x00000] in <filename
  at (wrapper managed-to-native)
MonoTouch.ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
  at MonoTouch.UIKit.UIViewController.get_View () [0x00000] in <filename
  at MyWebView.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication
app, MonoTouch.Foundation.NSDictionary options) [0x00000] in <filename
  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) [0x00000] in <filename
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in
<filename unknown>:0 
  at MyWebView.Application.Main (System.String[] args) [0x00000] in <filename
Error connecting stdout and stderr (

Reproducible: Always

Steps to Reproduce:
1.Create an iPhone Project with a MainWindow.xib. Change the scope of "window"
property to public. Add a ViewController.xib. 
2.Create a class name SnoopWindow inherited from UIWindow. 
3.Override ViewDidLoad method of ViewController class and adding the code:

AppDelegate applicationDelegate =

SnoopWindow snoopWindow = (SnoopWindow)applicationDelegate.window; 
Actual Results:  
The casting from UIWindow to SnoopWindow should be allowed

Expected Results:  
Exception was thrown. And the app was crashed.

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list