Discussion:
Activation Context Error in MMC snap-ins when using Windows Vista
(too old to reply)
alex
2007-02-22 02:22:15 UTC
Permalink
Hi,

Good Day to all!

I have been tasked by my team leader to convert our existing MMC snap-
in project to support Windows Vista. Our snap-in is very much working
in Windows XP but when I tried to run it in Windows Vista, this error
occurs.

First-chance exception at 0x772bfc53 in mmc.exe: 0xC015000F: The
activation context being deactivated is not the most recently
activated one.

Unhandled exception at 0x772bfc53 in mmc.exe: 0xC015000F: The
activation context being deactivated is not the most recently
activated one.

I took this error message in my Visual Studio 2005 or VS8.0.

BTW, this is the current setup:
- Visual Studio 2005 version 8.0.50727.762 w/ SP (Visual Studio 8.0
SP1 for Vista)
- Microsoft Management Console 3.0 version 6.0
- Windows Vista (TM) RC2 Evaluation copy. Build 5744
- Windows XP Professional with SP2

I had both Windows XP and Windows Vista installed in my PC but on
different HDD.

I can run my project using VS2005 under WinXP and worked fine but
fails when I'm using VS2005 under Windows Vista.

My MMC snapin project is taken from the samples in Platform SDK for
WinXP SP2.

The problem seems to come when you use
"AFX_MANAGE_STATE(AfxGetStaticModuleState());"

Below is my code:

HRESULT CStaticNode::OnMenuCommand(IConsole *pConsole,
IConsoleNameSpace *pConsoleNameSpace,
IPropertySheetProvider
*pPropertySheetProvider,
long lCommandID,
IDataObject *pDataObject,
IComponentData *pComponentData,
CComponentData *pCComponentData,
LONG cookie)
{
/////////////////////////////////////////////////
// Set to MFC state
/////////////////////////////////////////////////
AFX_MANAGE_STATE(AfxGetStaticModuleState());

switch (lCommandID)
{
case IDM_ADD_SERVER:
{
CPropertyPage* pBasePage[3];
CPropertySheet dlg; <<------ Activation context
errors occurs here!!! T_T
...
...
...
...
}
}

return S_OK;

Did someone encountered this problem before? Need help pls.

Thanks.
Jay
alex
2007-02-22 02:25:11 UTC
Permalink
This has some relation with this kind of problem...

http://groups.google.com.ph/group/microsoft.public.management.mmc/browse_thread/thread/8555cb415c4596c1/1644c80f73a89ac3?lnk=st&q=vista+mmc+activation+context&rnum=1#1644c80f73a89ac3

Can someone help me?

I cannot find any other sources in the internet about this bug.
I found other posts about this problem, but mostly unanswered.
Other posts, suggests tranferring codes from C++ to C#.NET. Well, that
is entirely impossible! Recoding a 6mons project just because the OS
doesn't support it. Ouch...

If anyone had experience this problem, pls. lets work together. :)
I'd be willing to discuss things up.

Anyone need addtional source codes to be posted, i'll gladly put them
up.
r***@rhbe.net
2007-02-23 06:56:03 UTC
Permalink
It's the theming I think. I ran into the same thing and fixed it by
adding this call which I found by going through the MFC source code in
Visual Studio 2005. In the init of the dll, I put this line:

CWinApp::InitInstance();
afxAmbientActCtx = FALSE;

Give it a try.
r***@rhbe.net
2007-02-23 07:15:38 UTC
Permalink
Realized I was ambiguous about which line fixed the problem. It was

afxAmbientActCtx = FALSE;

I didn't track this all the way through but if you're running Visual
Studio 2005 you can search for afxAmbientActCtx and you'll find it in
the mfc header files. There was always an issue with theming in MFC.
You had to be careful with activating it if it was already activated
etc. In MFC 8.0 they seem to have done something to fix the problem
but I never actually got a handle on it. I'm not working with it any
longer (MFC 8) but I do remember this annoyance.
alex
2007-02-23 08:41:35 UTC
Permalink
Thanks for the reply.

I'll do that. I'll try out your suggestion and post back the results.
alex
2007-02-26 06:58:58 UTC
Permalink
Post by r***@rhbe.net
Realized I was ambiguous about which line fixed the problem. It was
afxAmbientActCtx = FALSE;
I didn't track this all the way through but if you're running Visual
Studio 2005 you can search for afxAmbientActCtx and you'll find it in
the mfc header files. There was always an issue with theming in MFC.
You had to be careful with activating it if it was already activated
etc. In MFC 8.0 they seem to have done something to fix the problem
but I never actually got a handle on it. I'm not working with it any
longer (MFC 8) but I do remember this annoyance.
Thanks. it worked very well!!! ^_^

I never expect a 1-liner code would just do the trick.

I inserted the line... "afxAmbientActCtx = FALSE; " in the
InitInstance() function of my CWinApp class.

Thanks very much!
alex
2007-02-26 06:59:13 UTC
Permalink
Post by r***@rhbe.net
Realized I was ambiguous about which line fixed the problem. It was
afxAmbientActCtx = FALSE;
I didn't track this all the way through but if you're running Visual
Studio 2005 you can search for afxAmbientActCtx and you'll find it in
the mfc header files. There was always an issue with theming in MFC.
You had to be careful with activating it if it was already activated
etc. In MFC 8.0 they seem to have done something to fix the problem
but I never actually got a handle on it. I'm not working with it any
longer (MFC 8) but I do remember this annoyance.
Thanks. it worked very well!!! ^_^

I never expect a 1-liner code would just do the trick.

I inserted the line... "afxAmbientActCtx = FALSE; " in the
InitInstance() function of my CWinApp class.

Thanks very much!
alex
2007-02-26 06:59:23 UTC
Permalink
Post by r***@rhbe.net
Realized I was ambiguous about which line fixed the problem. It was
afxAmbientActCtx = FALSE;
I didn't track this all the way through but if you're running Visual
Studio 2005 you can search for afxAmbientActCtx and you'll find it in
the mfc header files. There was always an issue with theming in MFC.
You had to be careful with activating it if it was already activated
etc. In MFC 8.0 they seem to have done something to fix the problem
but I never actually got a handle on it. I'm not working with it any
longer (MFC 8) but I do remember this annoyance.
Thanks. it worked very well!!! ^_^

I never expect a 1-liner code would just do the trick.

I inserted the line... "afxAmbientActCtx = FALSE; " in the
InitInstance() function of my CWinApp class.

Thanks very much!
r***@rhbe.net
2007-02-27 01:36:00 UTC
Permalink
Yeah. It does quite a bit under the hood. It took a ridiculous amount
of time to figure out. Good luck with the conversion.

Loading...