RE: 0xC0150010: The activation context being deactivated is not active for the current thread of execution.
Hi Frank,
I recommend that you refer to this article to ensure that your application
obeyed the rules of activating/deactivating the ActivationContext:
SXS Activation Context --- Activate and Deactivate
http://blogs.msdn.com/junfeng/archive/2006/03/19/sxs-activation-context-acti
vate-and-deactivate.aspx
I extract some parts of the article and post it here for your reading
convenience:
==================================================================
To activate/deactivate an ActivationContext, call
ActivateActCtx/DeactivateActCtx.
Since components search their data in the most recent activated Activation
Context, care is neede to be taken when using Sxs technology.
1. Be sure to call ActivateActCtx when entering your isolation
boundary so that you don??t read data from other people??s activation
context. .
2. Be sure to call DeactivateCtx when leaving your isolation boundary
so that you don??t pollute other people??s activation context.
To enforce this rule, Sxs maintains activation contexts in a way like a
stack:
1. ActivateActCtx pushes the activation context to the top of the
stack, and it becomes the most recent activated activation context.
2. DeactivateActCtx pops the activation context from the top of the
stack, and the next one in the stack becomes the most recent activated
action context.
3. On deactivation, Sxs checks to see if the activation context to be
deactivated is on the top of the stack or not. If it is not the top of the
stack, Sxs throws one of the following two exceptions:
a. If the activation context is on the stack, but not the top of the
stack, Sxs throws exception STATUS_SXS_EARLY_DEACTIVATION (0xC015000F),
with the message ??The activation context being deactivated is not the most
recently activated one.??
b. If the activate context can not be found in the stack, exception
STATUS_SXS_INVALID_DEACTIVATION (0xC0150010) is thrown, with the message
??The activation context being deactivated is not active for the current
thread of execution.??
You may see those two exceptions occasionally. The most likely reason is
that someone calls ActivateActCtx on entrance, but forgets to call
DeactivateActCtx on exit.
To ensure that this never happen in your code, use __try/__finally:
ActivateActCtx(hActCtx, &dwCookie);
__try
{
??
}
__finally {
DeactivateActCtx(0, dwCookie);
}
If you don??t clean up the activation context stack correctly, someone on
top of you may try to clean up their stack, and end up with the
deactivation exceptions.
=======================================================================
Hope this helps. Also I appreciate your understanding that our managed
newsgroup may not be the best place for addressing those issues required
dump analysis. For such issues, it is recommended that you contact
Microsoft Customer Support Services (CSS) via telephone so that a dedicated
Support Professional can assist you in a more efficient manner. Please be
advised that contacting phone support will be a charged call.
To obtain the phone numbers for specific technology request please take a
look at the web site listed below.
http://support.microsoft.com/default.aspx?scid=fh;EN-US;PHONENUMBERS
If you are outside the US please see http://support.microsoft.com for
regional support phone numbers.
If you have any other questions or concerns, please feel free to let me
know.
Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
============================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================