Question

hi i have been using Visula studio 2008 i was able to build the code and while debugging my project in release mode i am getting this error

how to get rid of this "Native' has exited with code 1 (0x1)" Error

lst_0704.exe': Loaded 'C:\lst\bin\lst_0704.exe', Symbols loaded.

lst_0704.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'

lst_0704.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'

lst_0704.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'

The program '[6480] lst_0704.exe: Native' has exited with code 1 (0x1).

i have tried to change my project to debug mode as suggested in one of MSDN blogs but i am still getting this error

will there be any issue with command line arguments given in project properties?

Was it helpful?

Solution

This line does not necessarily indicate an error:

The program '[6480] lst_0704.exe: Native' has exited with code 1 (0x1).

It just means that your program's process (lst_0704.exe) has exited, presumably because you asked it to do so. The "native" part means that your application is compiled to native code, as opposed to managed code. And it's also telling you that the return code was 1.

Traditionally, when an application exits normally without any errors, it will return a code of 0. But that is not strictly required. There is really nothing in the operating system itself that checks these return codes—it is up to you to do so if you care.

I can't tell you exactly why your application is returning a code of 1 on exit, because you haven't posted any of your code. But my psychic powers tell me that there is probably a return 1; statement (or its functional equivalent) at the end of your main method. If you want the application to exit with a return code of 0, you'll need to change that to return 0;.

In Windows applications (as opposed to Console applications), the return code is typically the wParam of the WM_QUIT message that causes the application to terminate. In other words, the main message loop will look something like this:

MSG  msg;
BOOL bRet;
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
{
    if (bRet == -1)
    {
        // An error occurred
    }
    else
    {
        // Process the message
        TranslateMessage(&msg); 
        DispatchMessage(&msg); 
    }
} 

// GetMessage returned WM_QUIT, so return the exit code.
return msg.wParam; 

You cause the generation of the WM_QUIT message by calling the PostQuitMessage function, which takes a single parameter that specifies the exit code. That is the one that gets passed as the wParam and returned as the process's exit code. Again, it does not matter what code you return here, but it is traditionally 0 if the code is exiting normally with no errors.

OTHER TIPS

This exact error, but with a different underlying cause, was preventing me from starting execution of a new project. There were no other errors, exceptions, or any other indications about what was wrong.

My cause turned out to be due to creating the project as a console application, then switching it to a Windows application. The startup code is different and incompatible between the two types of projects. Replacing Program.cs with its static Main() method and modifying its namespaces, etc., from another project created as a Windows application resolved my error.

I hope this helps someone else who is confused by this unhelpful error message.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top