Re: How to set exit code of non-console app?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Chris Jobson (chris.jobson_at_btinternet.com)
Date: 09/27/04


Date: Mon, 27 Sep 2004 23:44:56 +0100

As I understand it the result of Main() is the application's exit code. If I
use Visual Studio to create a C# Windows Application and then modify Main()
to be:
[STAThread]
static int Main() {
Application.Run(new Form1());
return 1;
}
it seems to exit with an exit code of 1. Maybe I'm missing something because
I don't know what you mean by "Windows applications exit immediately,
leaving their windows still open." Surely if there are still windows open
then the application can't have exited (unless the windows are created by a
different thread - I don't know what happens in that case when the initial
thread exits).

Chris Jobson

"Peter Steele" <psteele@z-force.com> wrote in message
news:%23bMdlO9oEHA.1988@TK2MSFTNGP09.phx.gbl...
>I have a Windows application written in C# that I want to return a non-zero
>exit code when it it run. The problem is that as a Windows application,
>there doesn't seem to be a way to control this. The value returned by the
>Main function has no impact on the value returned by the application.
>Windows applications exit immediately, leaving their windows still open. Is
>there a way to change the value a Windows application exits with. Basically
>I want it to return 1 instead of 0. I need to do this because the
>application is launched by another application that checked for the exit
>code and this particular application expects that the program it launches
>to return a non-zero exit code.



Relevant Pages

  • Re: How to set exit code of non-console app?
    ... The problem is that as a Windows application, ... > Windows applications exit immediately, ... > code and this particular application expects that the program it launches ... > return a non-zero exit code. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to set exit code of non-console app?
    ... The problem is that as a Windows application, ... > Windows applications exit immediately, ... > return a non-zero exit code. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: tcl/tk on Windows: "This application has requested the Runtime to terminate it in an unusual way
    ... I assume you mean calling the 'exit' command. ... the proc 'quit' that you've written. ... Windows) as explicitly quitting Tk's even loop. ... explicitly destroy the root toplevel (a hint found via a google search, ...
    (comp.lang.tcl)
  • How to set exit code of non-console app?
    ... The problem is that as a Windows application, ... Windows applications exit immediately, ... return a non-zero exit code. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Exceptional Error
    ... to exit above the top directory. ... Kevin Spencer ... and the bicycle has to *want* to change. ... I am using IIS in Windows XP. ...
    (microsoft.public.dotnet.framework.aspnet)