[Mono-list] Re: [Gtk-sharp-list] Dos window - when launch apponWin32 OS - how to remove it ?

Kornél Pál kornelpal at hotmail.com
Fri Jul 15 16:20:56 EDT 2005


>Does this mean that using mono on windos will imply to have allways a
>dos box, no matter the value used for the /target option?

Yes, all the things I have written means this single fact.:) The console
window is dependent on the executable used to create the process (mono.exe
in this case) rather than the managed exe that is loaded by mono.exe

>Does this also mean that in the future, mono runtime on windows will
>allways generate a dos box withtout being a bug, according to your
>description?

This is not a bug because this is by design.:)

As long as mono.exe is marked as IMAGE_SUBSYSTEM_WINDOWS_CUI Windows will
create a new console window or attach mono.exe to its parent's console
window if it has one. By calling FreeConsole this could be detached (console
window will disappear if it was created for mono.exe) but at least a new
console window will flicker everytime you execute mono.exe with
/target:winexe because the console window will be created anyway but will be
closed as fast as possible.

There is a better solution: Marking mono.exe as IMAGE_SUBSYSTEM_WINDOWS_GUI.
In this case no console window will be created. The problem is that a
console window is required by /target:exe managed applications. In this case
you can call AttachConsole(ATTACH_PARENT_PROCESS); and it will result in
exactly the same behaviour as IMAGE_SUBSYSTEM_WINDOWS_CUI. The only problem
is that AttachConsole is implemented in Windows XP, Windows Server 2003 and
later. This is only a subset of Windows operating systems that Mono
supports.

Normally this nice solution could be used on Windows XP and 2003 and the
ugly FreeConsole sholution could be used on earlier Windows' but the problem
is that mono.exe itself has to be marked with different subsystem and thus
this would require two separate mono.exe that is a bad solution.

There is some explanation by someone else:
http://msdn.microsoft.com/msdnmag/issues/04/02/CQA/#QA3

Note that he suggest to use a com and an exe file but I think this is a more
lame solution that calling FreeConsole.

Kornél



More information about the Mono-list mailing list