Click here to Skip to main content
15,120,078 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
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.[^]

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) {
catch (...) {
finally {
   if (db_Conn)
Updated 31-Aug-12 5:42am
[no name] 31-Aug-12 10:54am
"when I change the outlook profile location"... perhaps you should examine why the crash goes away when you change the location.
T2102 31-Aug-12 11:12am
Unfortunately it's not consistent and may have been a coincidence. The article I reference indicates that the ole provider for outlook is meant to be run in STA instead of MTA. Otherwise you get an error such as " System.Data.OleDb.OleDbException: There are no MAPI clients installed on this machine. Install a MAPI client (like Outlook) on this machine." I think .NET and the provider may be the source of the problem, but I still can't figure out why it can't catch an exception.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900