P
Patrick Schmid [MVP]
I am trying to unload an unmanaged C++ Office 2007 add-in with code in
the add-in itself. In a managed add-in, this works without a problem,
but I can't get it to work with an unmanaged C++ one.
What I am trying to do is to set the Connect property of the Add in
Instance to false.
So the code for this is:
STDMETHOD(OnConnection)(IDispatch * Application,
AddInDesignerObjects::ext_ConnectMode ConnectMode,
IDispatch *AddInInst, SAFEARRAY **custom)
{
HRESULT hr = S_OK;
CComPtr<IDispatch> m_pAddInInstance;
IfFailGo(AddInInst->QueryInterface(__uuidof(IDispatch),
(LPVOID*)&m_pAddInInstance));
IfFailGo(m_pAddInInstance->QueryInterface(__uuidof(COMAddIn),
(void**)&addInInstance));
Error:
return hr;
}
With
protected:
COMAddIn * addInInstance;
---
Then I am trying to unload it using
addInInstance->put_Connect(false);
---
When I try this, the DLL is unloaded, followed by the unloading of
msvcr80d.dll and then Culture.dll
But then, I get a first-chance exception in the Office app (e.g.
Excel.exe): Access violation reading location ...
Followed by lots of more first-chance exception (all access violations),
but all for a different address. Eventually, I get a stack overflow.
Does anyone have any idea what I could be doing wrong?
Thanks,
Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
the add-in itself. In a managed add-in, this works without a problem,
but I can't get it to work with an unmanaged C++ one.
What I am trying to do is to set the Connect property of the Add in
Instance to false.
So the code for this is:
STDMETHOD(OnConnection)(IDispatch * Application,
AddInDesignerObjects::ext_ConnectMode ConnectMode,
IDispatch *AddInInst, SAFEARRAY **custom)
{
HRESULT hr = S_OK;
CComPtr<IDispatch> m_pAddInInstance;
IfFailGo(AddInInst->QueryInterface(__uuidof(IDispatch),
(LPVOID*)&m_pAddInInstance));
IfFailGo(m_pAddInInstance->QueryInterface(__uuidof(COMAddIn),
(void**)&addInInstance));
Error:
return hr;
}
With
protected:
COMAddIn * addInInstance;
---
Then I am trying to unload it using
addInInstance->put_Connect(false);
---
When I try this, the DLL is unloaded, followed by the unloading of
msvcr80d.dll and then Culture.dll
But then, I get a first-chance exception in the Office app (e.g.
Excel.exe): Access violation reading location ...
Followed by lots of more first-chance exception (all access violations),
but all for a different address. Eventually, I get a stack overflow.
Does anyone have any idea what I could be doing wrong?
Thanks,
Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed