[Mono-osx] [Mono-list] How do you use mkbundle2 for Mac OS X successfully?

Alex Shulgin alexander.shulgin at yessoftware.com
Fri Feb 19 11:56:04 EST 2010

(moved this to mono-osx list)

d_v wrote:
> 1)      a) When I double-click the output file of mkbundle, it auto opens a
> Terminal window (It is Applications/Utilities/Terminal.  About Terminal
> shows it is version 2.0.2) and outputs the following lines:
> Last login: Wed Feb 17 12:42:09 on ttys001
> $ /Program\ Files/My\ Software/MacFormShow/testDynStatic ; exit;
> After I close the WinForm it does not auto quit Terminal but outputs the
> following:
> logout
> [Process completed]
> Do you know of another/better way to launch a bundled application?

Ah, I got it.  You must be confusing Mono bundle (a collection of .Net 
assemblies packaged together into single natively executable file, 
optionally with Mono runtime included) and Mac OS X application bundle 
(a folder which name ends with ".app" containing special directory 

If you create the latter, say MyProgram.app, put a mkbundle-d native 
executable into it at designated location then you'll get a native Mac 
OS application which is run w/o terminal window when you click on it.

> 2)      What do you mean by "The unbundled WinForms app will hang just like
> that"   I did bundle it with mkbundle so I thought it shouldn't hang (was
> hoping anyway).

I mean that this problem can't be solved by using mkbundle, as it 
doesn't create something related to Mac OS application bundles which 
will then magically solve it.

> I am hoping someone has sample code or a link for this and in c# would be
> really nice.
> a.       Do you have any more info on how to use the "Winform support
> method" 

I don't really know if there's event or other notification means in 
WinForms which are triggered when system is being shutdown.  If there 
is, then probably it's mono implementation is incomplete or missing (or 
you have to explicitly specify that you want to handle the event).

> b.      Do you have an more info on how to "handle shutdown Apple Event
> manually (see AEInstallEventHandler(), kAEQuitApplication).

You'll need to P/Invoke the above Apple system call and provide a 
handler function in your C# code.  When user logs out or mac is 
shutdown, your method will be called and will have a chance to 
gracefully close the application or prevent system from shutting down 
(e.g. ask user to save changes in document).

This might be of some help: 


> From: Alex Shulgin [via Software]
> [mailto:ml-node+4597707-1155441064-165460 at n2.nabble.com] 
> Sent: February-19-10 08:13
> To: d_v
> Subject: Re: How do you use mkbundle2 for Mac OS X successfully?
> d_v wrote: 
>> I am having difficulty running bundles and using mkbundle. 
>> How do I: 
>> 1) Not see the Terminal window when I double-click the mkbundle 
>> output/bundled file: test3 
> I'm not sure what are you talking about as I never experienced this. 
> Does it happen only when you run bundled app?  Does it output anything 
> to the window?  BTW, could it probably be X11 window, not one from 
> Applications -> Utilities -> Terminal? 
>> 2) When I Launch the mkbundle output file in Mac OS X and the logout of
> the 
>> Mac with the mono application still running (and terminal window open),
> the 
>> Mac will hang and the application will not quit and I can't logout until I
>> 'force quit' mono. However while it is hanging I can either quit the 
>> terminal window or the application to close both windows (term and app)
> and 
>> then the logout works. 
> This is unrelated to use of mkbundle.  The unbundled WinForms app will 
> hang just like that.  To handle this you'll need support from WinForms 
> or handle shutdown Apple Event manually (see AEInstallEventHandler(), 
> kAEQuitApplication). 
>> 3) Sucessfully use mkbundle with the dynamic option and get no warnings. 
>> (please see below) 
> But are you really bothered by these warnings? 

More information about the Mono-osx mailing list