M
movalgirl
CoCreateInstance() fails with: 0x80040154 (CO_E_SERVER_EXEC_FAILURE)
will creating Outlook Object (OOM) from within Outlook ComAddin and
Outlook ClientExtension.
Hello all,
I have the following piece of code which is called both from Outlook
and from a an extra process (a formviewer) also started by Outlook.
This code fails on a regular basis with the error code (0x80040154 )
from within Outlook. For the external process (a formviewer) it works.
....
CComPtr<IDispatch> g_Outlook;
HRESULT hr;
CoInitialize(NULL);
CString sMsg;
CLSID clsid;
hr = ::CLSIDFromProgID( OLESTR("Outlook.Application"), &clsid);
if ( hr != S_OK )
{
LOGMSG (_WARNING, _T("Unable to resolve CLSID for Outlook
Application: 0x%08x " ), hr );
return eRetVal;
}
// output the CLSID to logfile for troubleshooting purposes
LPOLESTR uidstr;
hr=StringFromCLSID(clsid,&uidstr);
if (SUCCEEDED (hr))
{
sMsg.Format (_T("Got CLSID from Outlook.Application: %s"), uidstr);
LOGMSG (_DBUG, sMsg);
CoTaskMemFree(uidstr);
}
DWORD dwContext = CLSCTX_INPROC_SERVER;
hr = CoCreateInstance( clsid
,NULL
,dwContext
,IID_IDispatch
,(LPVOID*) &g_Outlook);
if ( hr != S_OK )
{
... }
will creating Outlook Object (OOM) from within Outlook ComAddin and
Outlook ClientExtension.
Hello all,
I have the following piece of code which is called both from Outlook
and from a an extra process (a formviewer) also started by Outlook.
This code fails on a regular basis with the error code (0x80040154 )
from within Outlook. For the external process (a formviewer) it works.
....
CComPtr<IDispatch> g_Outlook;
HRESULT hr;
CoInitialize(NULL);
CString sMsg;
CLSID clsid;
hr = ::CLSIDFromProgID( OLESTR("Outlook.Application"), &clsid);
if ( hr != S_OK )
{
LOGMSG (_WARNING, _T("Unable to resolve CLSID for Outlook
Application: 0x%08x " ), hr );
return eRetVal;
}
// output the CLSID to logfile for troubleshooting purposes
LPOLESTR uidstr;
hr=StringFromCLSID(clsid,&uidstr);
if (SUCCEEDED (hr))
{
sMsg.Format (_T("Got CLSID from Outlook.Application: %s"), uidstr);
LOGMSG (_DBUG, sMsg);
CoTaskMemFree(uidstr);
}
DWORD dwContext = CLSCTX_INPROC_SERVER;
hr = CoCreateInstance( clsid
,NULL
,dwContext
,IID_IDispatch
,(LPVOID*) &g_Outlook);
if ( hr != S_OK )
{
... }