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



The information in this article applies to:

  • Microsoft COM+ 1.5, when used with:
    • the operating system: Microsoft Windows XP

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 "Applies to" 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("TestProperty"); // This is the custom context property name.
_variant_t val("Hello"),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("The return value is %s\n",(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.
}

Modification Type:MajorLast Reviewed:8/25/2004
Keywords:ATdownload kbWinXPsp2fix kbfix kbbug kbWinXPpreSP2fix KB832098 kbAudDeveloper