[Mono-osx] NIB files in non-executable assemby problem

Hess, Philip J pjhess at purdue.edu
Thu Feb 9 19:02:23 UTC 2012


Chris,

If Window is Null, this probably means it hasn't been loaded yet from the nib. I don't know what your Initialize call does, but NSWindowController initializers don't actually load the nib file. That's done by the loadWindow method, which is invoked indirectly by calling the window method. Maybe you need to override loadWindow as discussed in Apple's docs if your app is not finding the nib file:

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindowController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40004152

Thanks.

-Phil

________________________________________
From: mono-osx-bounces at lists.ximian.com [mono-osx-bounces at lists.ximian.com] On Behalf Of Chris Hamons [chris.hamons at ni.com]
Sent: Thursday, February 09, 2012 12:32 PM
To: mono-osx at lists.ximian.com
Subject: [Mono-osx] NIB files in non-executable assemby problem

I'm working with monomac and am trying to port some code. I'm unsure if this is a problem with my code, with my project build settings, or an actual bug. Any help would be appreciated:

I have two assemblies of interest, one setup as a Library and the other as an Executable (that depends on the Library). The code in question is roughly:

Executable Assembly:

        static void Main (string [] args)
        {
            MyApplication.Run();
        }

Library Assembly:

        (MyApplication)
        public static void Run()
        {
            try
            {
                NSApplication.Init ();
                NSApplication.Main(new string[] {});
            }
            catch (Exception exception)
            {
            }
        }


       (AppDelegate)
       public override void FinishedLaunching (NSObject notification)
       {
             mainWindowController = new MyController();
             mainWindowController.Window.MakeKeyAndOrderFront(this);
      }


        // Call to load from the XIB/NIB file
        public MyController() : base ("MyController")
        {
            Initialize ();
        }


The Library Assembly also contains MyController.xib.


If I run the project as listed, mainWindowController.Window is null (and thus I crash) and in some conditions I get a print to Application Output about difficulty finding the xib file.

If I add a reference to MyController.xib in my executable assembly then I see my window just fine.

Is there any way I can make this work without having to add this reference? I've tried changing the build setting in MyController.xib in the Library assembly to no effect.

If my example is unclear, I can create a simple project that shows this if necessary.

Thanks,
--Chris


More information about the Mono-osx mailing list