Debugger Error in VC++.NET

Z

ziv

I am encountering a very strange error
Openning a Visual C++/Win32 Console project with mfc support, writing a simple Sleep(5000) function in the main and running the app in Debug mode (default settings). while closing the app in the middle of execution (click on the close window button) i am getting the following error
"Unhandled exception at 0x7c29ed41 (mfc71d.dll) in test2.exe: 0xC0000005: Access violation reading location 0xf78b78e8.

This behavior occurs only in debug mode configuration

We are encountering many problems in porting our code from VC6 to VC++.NET but we would like to solve this first..

Running Visual Studio.NET 7.1.3088, .NET Framework 1.1.4322 SP1, on Windows2000 Professional, SP

thanks in advance, ziv
 
O

Oleg Starodumov

I am encountering a very strange error:
Openning a Visual C++/Win32 Console project with mfc support, writing a simple Sleep(5000) function in the main and
running the app in Debug mode (default settings). while closing the app in the middle of execution (click on the close
window button) i am getting the following error:
"Unhandled exception at 0x7c29ed41 (mfc71d.dll) in test2.exe: 0xC0000005: Access violation reading location 0xf78b78e8."

This behavior occurs only in debug mode configuration.

We are encountering many problems in porting our code from VC6 to VC++.NET but we would like to solve this first...

Running Visual Studio.NET 7.1.3088, .NET Framework 1.1.4322 SP1, on Windows2000 Professional, SP4

When you click Close button, the default handler for the event calls ExitProcess,
thus triggering MFC cleanup. The problem is that the system starts a new thread
to call the handler, and therefore the cleanup is made on that thread, not on
the main thread (which is killed by ExitProcess by that time).

The solution is to register your own handler for Close, Ctrl-C and Ctrl-Break events
(using SetConsoleCtrlHandler function), handle these events and ask your main thread
to exit cleanly.

Regards,
Oleg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top