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

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


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:




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)

Library Assembly:

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

       public override void FinishedLaunching (NSObject notification)
             mainWindowController = new MyController();

        // 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.


More information about the Mono-osx mailing list