This question is out of CAPE-OPEN standard scope, but make me very puzzled.
Recently I tried to develop a property package, the development environment is visual C++ 2005, I create a ATL dll project, and part of the code like the following:
**************************
STDMETHODIMP CPropertyPackage::GetPhaseList(VARIANT * phaseLabels, VARIANT * stateOfAggregation, VARIANT * keyCompoundId)
{
if ((!phaseLabels)||(!stateOfAggregation)||(!keyCompoundId)) return E_POINTER;
............
............
return NOERROR;
}
***************************
This function has been finished, so I need to test this, I create a MFC program "DllTester" like the following:
*******************
//pCapeThermoPhases has been initialized
//phaseLabels, stateOfAggregation and keyCompoundId are all VARIANT pionter
phaseLabels=NULL; // I set the phaseLabels=NULL to test the dll, of course it will cause an error !
HRESULT hr=pCapeThermoPhases->GetPhaseList(phaseLabels, stateOfAggregation,keyCompoundId) ;
if(FAILED(hr)) AfxMessageBox(_T("GetPhaseList failed !!!"));
******************
The result is : The DllTester popup a warning messagebox ,then collapses and doesn't come into the
" if(FAILED(hr)) AfxMessageBox(_T("GetPhaseList failed !!!")); "
the warning's caption is "Microsoft Visual C++ Debug Library" and context is "This application has requested the Runtime to terminate it in an unusual way."
Then I finded if the interface function return E_FAIL, E_POINTER, E_UNEXPECTED even ECapeInvalidArgumentHR and so on , the DllTester all will collapse. So I want to know how to prevent the main program collapse when the returned HRESULT of the interface function is error?
In the Microsoft's MSDN, there are some remarks :
The error code is a unique number that is assigned to represent the exception. Each exception is mapped to a distinct HRESULT. When managed code throws an exception, the runtime passes the HRESULT to the COM client. When unmanaged code returns an error, the HRESULT is converted to an exception, which is then thrown by the runtime.
I find the visual C++ is unmanaged code, whether this reason causes the collapsion ?