Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PassthroughAPP crashes when compiled in VS 2005

81 views
Skip to first unread message

Valen....@gmail.com

unread,
Aug 22, 2006, 2:58:02 PM8/22/06
to
If anybody has that problem here is the solution:

The main reason for the crash is that critical section is not
initialized before Lock is called.
In order to fix that you need to call _AtlInitialConstruct() method.

Here is the fixed method from the ProtocolCF.inl


template <class Factory, class Protocol, class FactoryComObject>
inline HRESULT CMetaFactory<Factory, Protocol, FactoryComObject>::
CreateInstance(Factory** ppObj)
{
ATLASSERT(ppObj != 0);
if (!ppObj)
{
return E_POINTER;
}

HRESULT hr = E_OUTOFMEMORY;
void* pv = static_cast<void*>(CreatorClass::CreateInstance);
FactoryComObject* p = 0;
ATLTRY(p = new FactoryComObject(pv))
if (p != NULL)
{
p->SetVoid(pv);
p->InternalFinalConstructAddRef();
hr = p->_AtlInitialConstruct();
hr = p->FinalConstruct();
p->InternalFinalConstructRelease();
if (FAILED(hr))
{
delete p;
p = 0;
}
}
*ppObj = p;
return hr;
}

Best regards,
Valentin Ivanov.

0 new messages