Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crash filling data adapter

I am perplexed figuring out why a malformed query of a gmail account in outlook crashes my application instead of simply raising an exception. Seems that there is an uncaught win32 exception based on calling the code from unmanaged C++. The error goes away when I change the outlook profile location. I still don't understand why my .NET code could not catch the exception as I had nested > 20 exceptions to try to catch the issue.

I also can't directly debug the code in .NET since I am unable to set the STAAttribute and my compiler Visual Studio 2010 Professional doesn't allow me to debug C++/CLI code. http://winterdom.com/2007/02/jetmapiandsta

The query error is simple with # missing on a date SELECT * FROM inbox WHERE Body Like '%BWIC%' And rECEIVED>=#07/26/2012

I've tried adding many exceptions to the catch statement, but can't prevent the crash.

System::Data::DataSet ^db_DataSet=gcnew System::Data::DataSet;  
int const Fill_Result=db_Adapter.Fill(db_DataSet);
}
catch (System::Exception ^ex) {
    ex;
}
catch (...) {
   ;
}
finally {
   if (db_Conn)
       db_Conn.close();
}
like image 315
SyntaxError Avatar asked Nov 13 '22 02:11

SyntaxError


1 Answers

Take a look at This thread. It may be helpful.

According to it you can catch the exception in native environment and throw an exception into the managed world.

#include <exception>


 try
{
    try
    {
        Application::Run(gcnew frmMain()); 
    }
    catch(const exception& ex)
    {
        throw gcnew System::Exception(gcnew System::String(ex.what()));
    }
} 
catch (Exception^ ex) 
{ 
    LogAndExit(ex); 
} 
catch (...) 
{ 
    LogAndExit(); 
}
like image 64
babak Avatar answered Nov 15 '22 05:11

babak