CreateEx Causes an unhandled exception. The deactivated activation context is not the last activated

itsAnalysisDataTable.CreateEx( WS_EX_CLIENTEDGE, AfxRegisterWndClass( CS_DBLCLKS, LoadCursor( NULL, IDC_ARROW ), (HBRUSH)::GetStockObject( NULL_BRUSH ), NULL ), "AnalysiysTable", WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, dialogItemRect, this, IDC_ANALYSIS_DATA_TABLE ); 

This line cost me two days without a decision. itsAnalysisDataTable is a Windows user control that has CWnd as its great great parent. The control was successfully used in other steps without any problems in our code. this is CPropertyPage.

The problem I have is the causes of the line (and it does it every time) Unhandled exception at 0x76f7fd5c in MyProduct (x64) .exe: 0xC015000F: the deactivated activation context is not the last activated.

An exception occurs in the 32-bit version. I am on Windows 7 x64, VS 2008.

What I already tried:

  • Enabling the win32 exception interrupt in the debugger. An exception does not occur (except for exceptions from the first chances, which in our code are many and have no effect)
  • Recompilation of the whole project
  • Debugging OnCreate handler for exception management.

Call stack:

 ntdll.dll!0000000076f7fd5c() [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] kernel32.dll!0000000076df42d3() mfc90d.dll!AfxDeactivateActCtx(unsigned long dwFlags=0, unsigned __int64 ulCookie=2077018657900210161) Line 260 + 0x19 bytes C++ 

remarks:

  • If I skip the WS_CHILD flag, an exception does not occur, but OnCreate is also not called in the control!
  • If I ignore the exception and continue, the application works fine, management also works fine.
  • A call to AfxSetAmbientActCtx (FALSE) during application startup throws an exception. But I think this is a hack if I can not justify it.
+6
source share
5 answers

After many of them, I found an easy way to track the root problem - go to Debug -> Exceptions and enable ALL Thrown exceptions. Then you will find that there is another exception that fires when being quietly caught, but ruining the activation context. After correcting the first exception, the activation context exception will not occur.

+11
source

It turns out mine was associated with an uninitialized member in the class for controlling violations. Initializing the variable in the constructor fixed the problem. Therefore, I did not have to resort to AfxSetAmbientActCtx (FALSE)

+6
source

Calling AfxSetAmbientActCtx (FALSE) during an init application throws an exception. But I think this is a hack, if only I can not justify it.

The discussion in MS Connect β€œMFC default exception handling causes activation context problems” can help you justify the hack, which is a workaround for Microsoft.

+3
source

Had the same problem.

In my case, I read the file from the path, and I accidentally deleted this file. The problem with returning the file is resolved.

0
source

There were some mysterious crashes in the program that hosted IE, and several ActiveX controls.

It displays an earlier division by zero (one of the AX controls), which ultimately caused this exception and the subsequent violation of access rights.

0
source

Source: https://habr.com/ru/post/898654/


All Articles