Jump to content
  • Advertisement
Sign in to follow this  
Toolmaker

C++/COM: The activation context being deactivated is not active for the current threa

This topic is 3312 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on an MFC/COM application, and since I've changed a certain part of the COM DLL we use, this errors show up when creating a new CDialog instance: The activation context being deactivated is not active for the current thread of execution. I'm having a little bit of trouble understanding the exception, because apparantly it has to do with activation contexts, but we don't seem to be using those in our COM interface. None of the calls ever calls one of the activation contexts. Googling doesn't help much because they all turn up the same information. Anyone has some information on this?

Share this post


Link to post
Share on other sites
Advertisement
MFC implicitly uses activation contexts. One is setup when AfxWinInit() is called and each MFC User DLL has an activation context. IIRC, this problem usually goes away by placing AFX_MANAGE_STATE(AfxGetStaticModuleState()); at the beginning of exported functions in MFC User DLLs.

Share this post


Link to post
Share on other sites
That's weird... I tried tracing through some of the MFC code, and I eventually stumbled upon the a call to AFX_MANAGE_STATE(pThis->m_pModuleState);

So it appears that part *is* already called underwater, which makes this even weirder...

Share this post


Link to post
Share on other sites
Keep in mind that the AFX_MANAGE_STATE() calls are scoped global setters. When you use the AFX_MANAGE_STATE() macro, it sets the global state to the specified state for as long as the AFX_MANAGE_STATE()'s scope exists and then reverts the state when the scope exits. So the existence of one AFX_MANAGE_STATE() macro does not mean that the right module state is set as the global state for any contained scopes.

Alternately, it could mean that you have a buffer overrun somewhere that's causing a AFX_MANAGE_STATE() to revert to the wrong state, though that usually has other symptoms.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!