SYMPTOMS
This article describes a new Microsoft COM+ feature that is named MiniJIT, and how it can be used to set components with just-in-time (JIT) to be instantiated in the context of the caller.
When you use the JIT Activation service in COM+, the COM+ component must join its own context. To allow JIT-activated components to join the context of its caller, MiniJIT is included in the COM+ 1.0 Rollup fix 28. With MiniJIT enabled, a component can take part in JIT activation and can still be activated in the context of its caller. MiniJIT also makes sure that the
IObjectControl::Activate method and the
IObjectControl::Deactivate method are appropriately called, and that the transaction and the state of the parent (component of the caller) are not affected when the child component calls any of the following methods:
- IObjectContext::SetComplete
- IObjectContext::SetAbort
- IObjectContext::EnableCommit
- IObjectContext::DisableCommit
Note With MiniJIT enabled on a component , all the component and application property settings other than JIT that are mentioned in the following article still must be set correctly to get the component activated in the context of the caller:
261096 How to activate a COM+ component in the context of its caller
Steps to enable MiniJIT
- Make sure that COM+ Rollup 28 or later is installed on the the computer where you are creating the COM+ object.
- Add the following value to the registry to enable MiniJIT for that computer:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\COM3\
DWORD value: MiniJITEnabled = 1
- Set all the component and application property settings other than JIT that are mentioned in the following article:
261096 How to activate a COM+ component in the context of its caller
- In the component properties, set the following options to let the COM+ runtime determine that the object that you are creating has MiniJIT enabled:
- Enable Just In Time Activation
- Must be activated in callers context
You must correctly identify the candidate components for MiniJIT. Before you apply MiniJIT, you must make sure that these components can be instantiated in the context of the caller. The components must meet the following requirements:
- These components must not make use of any COM+ services other than JIT (if necessary).
- The component or the components that have MiniJIT enabled must always be called from another component or other components in the same process. The components that have MiniJIT enabled should not be called from component or components, or a client or clients, in another process. Microsoft recommends that you add components that have MiniJIT enabled to a Library package. This makes sure that the object is created in the process of the callers.
- The component or the components that have MiniJIT enabled must always be called from another component with the same threading model. This make sure that the component or the components can be instantiated on the same Thread or Apartment.
If you do not meet these requirements, the component instantiation may fail with the following error:
0x80004024: The specified activation could not occur in the client context as specified.
Differences between normal JIT and MiniJIT
- The ObjectControl_Activate method for the MiniJIT object is called immediately after you create the object and not when the first method is called. In a typical JIT scenario, the ObjectControl_Activate method is called when the first method call is made.
- The ObjectControl_Deactivate method for the MiniJIT object is only called when the calling object is destroyed. The Deactivate method of the MiniJIT object is not called immediately after the SetComplete method or the SetAbort method call is made. The Deactivate method is not called even after its last outstanding reference is released. In the typical JIT case, the ObjectControl_Deactivate method is called after the SetComplete method or the SetAbort method, or when the last reference is released.