Microsoft KB Archive/165605

= PRB: Using MFC OLE Components with Transaction Server =

Article ID: 165605

Article Last Modified on 8/18/2005

-

APPLIES TO

 Microsoft Transaction Services 1.0 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.2 Professional Edition

 Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q165605

<div class="symptoms_section">

SYMPTOMS
When registering and viewing a Microsoft Foundation Class (MFC) OLE component with the Microsoft Transaction Server Explorer, the following warning appears:

Some of the objects properties were missing or damaged. This can occur if the registry entries associated with the item are changed by some other program. Damaged items must be deleted and re-created.

<div class="cause_section">

CAUSE
MFC inproc servers do not register their interfaces in the interface section of the registry. When they are configured to run in a Microsoft Transaction Server package, the interfaces must be registered so that COM can marshal the interfaces or use OLEAUT32. Because the information is not in the registry, you receive an E_NOINTERFACE error, 80004002.

<div class="resolution_section">

RESOLUTION
To resolve this problem, register the interfaces. See the revised DllRegisterServer code in the "More Information" section of this article.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a problem in Transaction Server version 1.0.

<div class="moreinformation_section">

MORE INFORMATION
The following code is a revised DllRegisterServer from an MFC server that should register the interface of an automation object. The interface is registered by the call to RegisterTypeLib, as long as the interface is described by the type library.

Sample Code
STDAPI DllRegisterServer(void) {      USES_CONVERSION; AFX_MANAGE_STATE(AfxGetStaticModuleState); COleObjectFactory::UpdateRegistryAll;

ITypeLib *pTLB; OLECHAR *pModuleName; HRESULT hr = S_FALSE; TCHAR fileName[MAX_PATH]; if(!GetModuleFileName(AfxGetApp->m_hInstance, fileName,MAX_PATH)) return hr; pModuleName = T2OLE(fileName); hr=LoadTypeLib(pModuleName,&pTLB); if(FAILED(hr)) return hr;

hr=RegisterTypeLib(pTLB,pModuleName,NULL); pTLB->Release;

return hr; }

<div class="references_section">