S
Sebastian Lehmann
Hi,
i implement the Visio type library to use Visio functions in my MFC
application. All works fine, but my app, an instance of
Visio::IVApplicationPtr couldn't be released without a crash of my
application.
This is the code:
HRESULT hr;
Visio::IVApplicationPtr app;
hr = CoInitialize(NULL);
if (FAILED(hr))
return;
if (!app.GetInterfacePtr())
{
if ( !SUCCEEDED(app.GetActiveObject(Visio::CLSID_Application)) )
{
app.CreateInstance(Visio::CLSID_Application);
}
}
if (!app.GetInterfacePtr())
return;
/* Doing something with the instance of Visio
...
*/
// first release the page, doc and so on
page->Release();
pages->Release();
doc->Release();
docs->Release();
// now the app
app->Quit();
app->Release();
The last line (app->Release) throws an exception, i can't handle (i tried it
with try{...}catch(_com_error &err){...}). When i leave the method, this
code is located in, my application crashes because of unhandled exceptions.
Can anybody tell me how to release the app in correct way?
Thanks in advance for any answers,
Sebastian.
==================
Visual Studio 6 SP5
Visio 2002 SDK
i implement the Visio type library to use Visio functions in my MFC
application. All works fine, but my app, an instance of
Visio::IVApplicationPtr couldn't be released without a crash of my
application.
This is the code:
HRESULT hr;
Visio::IVApplicationPtr app;
hr = CoInitialize(NULL);
if (FAILED(hr))
return;
if (!app.GetInterfacePtr())
{
if ( !SUCCEEDED(app.GetActiveObject(Visio::CLSID_Application)) )
{
app.CreateInstance(Visio::CLSID_Application);
}
}
if (!app.GetInterfacePtr())
return;
/* Doing something with the instance of Visio
...
*/
// first release the page, doc and so on
page->Release();
pages->Release();
doc->Release();
docs->Release();
// now the app
app->Quit();
app->Release();
The last line (app->Release) throws an exception, i can't handle (i tried it
with try{...}catch(_com_error &err){...}). When i leave the method, this
code is located in, my application crashes because of unhandled exceptions.
Can anybody tell me how to release the app in correct way?
Thanks in advance for any answers,
Sebastian.
==================
Visual Studio 6 SP5
Visio 2002 SDK