Problem in COleObjectFactory::UpdateRegistryAll in VC.Net

  • Thread starter Thread starter Devender Khari
  • Start date Start date
D

Devender Khari

Hi Friends,

In our Automation server on VC++ 6.0, we are calling a static function,
UpdateRegistryAll(), of COleObjectFactory class
to register a list of factory objects of the server. In addition to the
interfaces, these factory objects includes a COleTemplateServer object as a
member object of the CWinApp derived class. The function UpdateRegistryAll
was registering all the interfaces successfully in VC6 but in VC7 it's just
registering one interface. This is because the second factory is the
COleTemplateServer and registration for this fails, after which the
registration does not proceed further leaving the remaining interfaces
unregistered. On debugging in source code for these classes I found that the
implementation of COleObjectFactory::UpdateRegistry is changed from VC6 to
VC7. I searched the MS knowledgebase but couldn't found any relevant
article. Please tell me if there's any clean was of getting all the
factories registrered.

Thanks a lot.

Regards,
Devender Khari
 
I found the answer to this one. This was caused by a v 7.1 fix in the
Microsoft code (in UpdateRegistry) which uncovered another Microsoft
bug.

The solution is to remove the COleTemplateServer m_server in the
application object and all references to it. This only works if you are
not using the COleTemplateServer m_server.

This COleTemplateServer m_server code is put in by Microsoft when you
create an MFC doc/view project with Automation enabled. It is still put
in there in VC .Net 2003 v 7.1 and the call to UpdateRegistryAll fails.

Warm Regards,
Steve Graber
 
Thanks Steve for your response. We have done the following to work around
this problem.

We have derived our own class CMyOleObjectFactory from COleObjectFactory and
calling its UpdateRegistryAll which behaves like the earlier version. The
actual code changes are appended below.

Thanks again,
Devender...

//Included these three lines for header
#if !defined(CRIT_OBJECTFACTORYLIST)
#include "afximpl.h"
#endif //!CRIT_OBJECTFACTORYLIST

//Then defined my own class
class CMyOleObjectFactory:public COleObjectFactory
{
public:
static BOOL PASCAL UpdateMyRegistryAll(BOOL bRegister);
BOOL UpdateRegistry(BOOL bRegister)
{
COleObjectFactory::UpdateRegistry(bRegister);
return TRUE;
}
};

//Then replaced the call to COleObjectFactory::UpdateRegistryAll() with the
following line
CMyOleObjectFactory::UpdateMyRegistryAll(TRUE);

//Function definition
BOOL PASCAL CMyOleObjectFactory::UpdateProbeRegistryAll(BOOL bRegister)
{
AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
AfxLockGlobals(CRIT_OBJECTFACTORYLIST);
COleObjectFactory* pFactory;
for (pFactory = pModuleState->m_factoryList;pFactory != NULL; pFactory =
pFactory->m_pNextFactory)
{
((CMyOleObjectFactory*)pFactory)->UpdateRegistry(bRegister);
}
AfxUnlockGlobals(CRIT_OBJECTFACTORYLIST);
return TRUE;
}
 
Back
Top