Microsoft KB Archive/832098

= FIX: The flow of custom context properties between object contexts does not work in COM+ =

Article ID: 832098

Article Last Modified on 8/25/2004

-

APPLIES TO


 * Microsoft COM+ 1.5, when used with:
 * Microsoft Windows XP Professional

-





SYMPTOMS
Every Microsoft COM+ object that is created is associated with exactly one context that provides the services. The context is a list of named properties. For example, the named properties may be Internet Information Services (IIS) intrinsics like Application, Session, Request, and Response. When one object creates another object, most of the object context properties of the first object are automatically copied into the context of the second object. This automatic context property flow through transitively created objects is useful.

However, the current COM+ implementation does not support the flow of custom context properties. Built-in context properties are flowed during object creation and object calls.



CAUSE
The current COM+ implementation does not support the flow of custom context properties.



RESOLUTION
Support for flowing the custom context properties has been added in COM+ 1.5.

Service pack information
To resolve this problem, obtain the latest service pack for Microsoft Windows XP. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

322389 How to obtain the latest Windows XP service pack

Hotfix information
A hotfix is scheduled to be included in Microsoft Windows XP COM+ 1.5 Rollup Package 6.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section. This problem was first corrected in Microsoft Windows XP Service Pack 2.



MORE INFORMATION
This bug is a behavior change for the IContextProperties interface that can be retrieved from the Microsoft Component Object Model (COM) context in a COM+ activated object. With this behavior change, callers of the IContextProperties::SetProperty method can set named property/value pairs of their own. These properties must follow the following restrictions:
 * The properties must have a name that is less than 255 characters long.
 * Only 32 properties can exist.
 * The type of the value of each property must be a VT_BSTR type.

Use this sample code to reproduce the behavior:

Caller code
IObjectContext *pOC;

hr=CoGetObjectContext(IID_IObjectContext,(void**)&pOC);

if(hr!=S_OK) return -1;

IContextProperties *pCP;

hr=pOC->QueryInterface(IID_IContextProperties,(void**)&pCP);

if(hr!=S_OK) return -1;

_bstr_t name(&quot;TestProperty&quot;); // This is the custom context property name.

_variant_t val(&quot;Hello&quot;),val1;

hr=pCP->SetProperty(name,val); // Set the value of the custom context property.

if(hr!=S_OK) return -1;

IMyTestClass* pCls; CoCreateInstance(CLSID_MyTestClass,NULL,CLSCTX_SERVER,IID_IMyTestClass,(void**)&pCls); val1=pCls->GetContextProperty(name);

printf(&quot;The return value is %s\n&quot;,(char*)((_bstr_t)val1));

Callee code
STDMETHODIMP CMyTestClass::GetContextProperty(BSTR name, VARIANT *val)

{

// Add your implementation code here.

IObjectContext *pOC;

HRESULT hr=CoGetObjectContext(IID_IObjectContext,(void**)&pOC);

if(hr!=S_OK) return E_FAIL;

IContextProperties *pCP;

hr=pOC->QueryInterface(IID_IContextProperties,(void**)&pCP);

if(hr!=S_OK) return E_FAIL;

hr=pCP->GetProperty(name,val);

// Get the custom context property.

if(hr!=S_OK) return E_FAIL;

// Add your other code here.

}

Additional query words: winxp wincom+ kbWinXPpreSP2COMRollup6Fix DCR QXP

Keywords: kbbug kbfix kbwinxpsp2fix kbwinxppresp2fix atdownload KB832098

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.