R
RalphTheExpert
I'm getting different behavior if my code is running under the
debugger or not.
I have modified Winmain to look like this:
// Copyright (C) 2002 Microsoft Corporation
// All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER
// EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF
// MERCHANTIBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// Requires the Trial or Release version of Visual Studio .NET
Professional (or greater).
#include "stdafx.h"
#include "frmMain.h"
#include "MyException.h"
using namespace VCNET;
[System::STAThreadAttribute]
void __stdcall WinMain()
{
try
{
Application::Run(new frmMain());
}
catch (MyException* pMyException)
{
// Show the exception to the user.
MessageBox::Show
(
System::String::Concat
(
MyException->ShowFullMessage(),
S"\r\n\r\n",
S"Internal failure. Program terminates."
),
S"Internal failure. Program terminates.",
MessageBoxButtons::OK,
MessageBoxIcon::Error
);
}
}
In a button handler I throw a MyException.
Under the debugger, the exception is caught in WinMain and a proper
dialog box is displayed.
If I run the executable (either Release or Debugger builds) then the
exception is not caught and the system displays an unhandled exception
message. The unhandled message displays the proper information.stored
in the MyException object.
Admittedly, the exception is being thrown from a function thirty levels
of procedure call between the function and WinMain() through a bunch of
system dlls.
Nonetheless, I would not expect different behavior if the program is
running under the debugger and without the debugger.
debugger or not.
I have modified Winmain to look like this:
// Copyright (C) 2002 Microsoft Corporation
// All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER
// EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF
// MERCHANTIBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// Requires the Trial or Release version of Visual Studio .NET
Professional (or greater).
#include "stdafx.h"
#include "frmMain.h"
#include "MyException.h"
using namespace VCNET;
[System::STAThreadAttribute]
void __stdcall WinMain()
{
try
{
Application::Run(new frmMain());
}
catch (MyException* pMyException)
{
// Show the exception to the user.
MessageBox::Show
(
System::String::Concat
(
MyException->ShowFullMessage(),
S"\r\n\r\n",
S"Internal failure. Program terminates."
),
S"Internal failure. Program terminates.",
MessageBoxButtons::OK,
MessageBoxIcon::Error
);
}
}
In a button handler I throw a MyException.
Under the debugger, the exception is caught in WinMain and a proper
dialog box is displayed.
If I run the executable (either Release or Debugger builds) then the
exception is not caught and the system displays an unhandled exception
message. The unhandled message displays the proper information.stored
in the MyException object.
Admittedly, the exception is being thrown from a function thirty levels
of procedure call between the function and WinMain() through a bunch of
system dlls.
Nonetheless, I would not expect different behavior if the program is
running under the debugger and without the debugger.