Hi,Gurus:
I got a ATL COM+ component (VC++ 2003 7.1), inside IDL Method1 (COM
Method), I call another Class Method2 (C++ class), the Method2 throw a
custom excetption
throw CBusError (_T("Custom"),_T("1407"));
in Method1
try {
...
Class1.Method2()
}
catch(CErrorBase& e)
{
}
catch(...)
{
}
when compile with /O2 (Release Mode), I got a unexpected error, the error
only by catch(...), not by CErrorBase
but when compiled with /O1 (Release Mode) or in debug mode, it work as
expected the error caught by CErrorBase
also in Method2, I have
std::string strMessageCode = "1234";
std::string strMessageSeverity = "323";
cstring cx1=("LA1748");
if ((strMessageCode== cx1))
throw CBusError(_T("ALLTEL"),_T("LA1407"));
else
throw CBusError (_T("ALLTEL"),_T("LA1407"));
but if I change
if ((strMessageCode== cx1)) to
if (1==2)
it work as expected even under /O2 (Release Mode)
so what is my problem?
Memory Corruption????
O2 Bug in VC++????
please advice.
Thanks in advance.
class CErrorBase
{ public:
CErrorBase() ;
CErrorBase(IID IID,LPTSTR Source,CComBSTR UserID,LPCSTR
szLocation) ;
virtual ~CErrorBase ();
public:
tstring m_strErrorDescr;
CLSID m_IID;
protected:
void LogTxtError() ;
CComBSTR m_UserID;
cstring m_szLocation;
tstring m_szSource;
CComBSTR m_orgerrmsg;
public:
HRESULT hrError;
CComBSTR CisUserID();
virtual void LogError()=0;
void SetVar(IID IID,LPTSTR Source,CComBSTR UserID,LPCSTR szLocation)
;
void
LogErrorObject(ErrorObjectWrapper<PINFRASTRUCTUREL ib::ErrorObject> &Err);
} ;
class CBusError : public CErrorBase
{
public:
CBusError(IID IID,LPTSTR Source,CComBSTR UserID,LPCSTR
szLocation,CComBSTR bstrErrorNo);
CBusError(LPTSTR Source,CComBSTR bstrErrorNo,LPCSTR lpErrMsg) ;
CBusError(LPTSTR Source,CComBSTR bstrErrorNo) ;
private:
CComBSTR m_bstrErrorNo;
public:
virtual void LogError();
};