mspocketpc.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

try/catch

 
Post new topic   Reply to topic    mspocketpc.org Forum Index -> Developers
Author Message
Lisa Pearlson



Joined: 15 Aug 2007
Posts: 446

PostPosted: Mon Feb 25, 2008 8:58 pm    Post subject: try/catch Reply with quote

Hi,

My debug output shows an exception when using CArchive::ReadString() beyond
the end of the file.
I thought that by handling exceptions, I could prevent the debug output for
them:

CFile f;
if (f.Open(_T("\\Temp\\test.txt"), CFile::modeRead)) {
CArchive ar(&f, CArchive::load);
CString s;
try {
while (ar.ReadString(s)) {
DEBUGMSG(1, (_T("ReadString: %s\r\n"), s));
}
} catch (CArchiveException* e) {
e->ReportError(); // never gets called!
e->Delete();
}
}

However, output is still shown for CArchiveException::endOfFile, and my
exception handler is never called.
Yes, I provided the /EHsc (and tried deprecated /GX) compiler options, set
via Project Settings/C++/Exception Handling in VS 2005.

Any clues?

Lisa

Archived from group: microsoft>public>pocketpc>developer
Back to top
View user's profile Send private message
dbgrick



Joined: 15 Aug 2007
Posts: 173

PostPosted: Mon Feb 25, 2008 12:18 pm    Post subject: RE: try/catch Reply with quote

Try putting your CArchive ar(...) in your try catch. The error may be at the
archive constructor.

Regards,
Rick D.

"Lisa Pearlson" wrote:

> Hi,
>
> My debug output shows an exception when using CArchive::ReadString() beyond
> the end of the file.
> I thought that by handling exceptions, I could prevent the debug output for
> them:
>
> CFile f;
> if (f.Open(_T("\\Temp\\test.txt"), CFile::modeRead)) {
> CArchive ar(&f, CArchive::load);
> CString s;
> try {
> while (ar.ReadString(s)) {
> DEBUGMSG(1, (_T("ReadString: %s\r\n"), s));
> }
> } catch (CArchiveException* e) {
> e->ReportError(); // never gets called!
> e->Delete();
> }
> }
>
> However, output is still shown for CArchiveException::endOfFile, and my
> exception handler is never called.
> Yes, I provided the /EHsc (and tried deprecated /GX) compiler options, set
> via Project Settings/C++/Exception Handling in VS 2005.
>
> Any clues?
>
> Lisa
>
>
>
>
Back to top
View user's profile Send private message
James Hayhurst



Joined: 28 Sep 2007
Posts: 3

PostPosted: Wed Feb 27, 2008 10:26 pm    Post subject: Re: try/catch Reply with quote

Does it throw an actual object, a ref to an object or a pointer to an
object?


"Lisa Pearlson" wrote in message @TK2MSFTNGP03.phx.gbl...
> Hi,
>
> My debug output shows an exception when using CArchive::ReadString()
> beyond
> the end of the file.
> I thought that by handling exceptions, I could prevent the debug output
> for
> them:
>
> CFile f;
> if (f.Open(_T("\\Temp\\test.txt"), CFile::modeRead)) {
> CArchive ar(&f, CArchive::load);
> CString s;
> try {
> while (ar.ReadString(s)) {
> DEBUGMSG(1, (_T("ReadString: %s\r\n"), s));
> }
> } catch (CArchiveException* e) {
> e->ReportError(); // never gets called!
> e->Delete();
> }
> }
>
> However, output is still shown for CArchiveException::endOfFile, and my
> exception handler is never called.
> Yes, I provided the /EHsc (and tried deprecated /GX) compiler options, set
> via Project Settings/C++/Exception Handling in VS 2005.
>
> Any clues?
>
> Lisa
>
>
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Catch RS232_DETECT Event Hi, in my App i collect barcodes with a PPC 2003 The codevalues are placed in a listview. When the user now put the scanner into i want to stop collecting Barcodes and store the values into a textfile. I find something about

Catch Email sent Event From Device I have an application which runs as a background service. [It include both module of C# and C++] Now I wants to do some insertion in the database for every email sent from the device. I know How to catch email recieve event by C# but Can't able to get any

help to catch notifications on ppc using imapisession::Advis have quoted the code below. Hope that anyone can give an idea to make it work in the pocket PC/Smartphone platform Hi, Here is a code to catch notifications on ppc using But it doesn't work and we never get notified when new mails co

how to catch Email sent event in windows mobile 5.0 How can I catch the email sent event in windows mobile 5.0. I have to do some DB insertion on the particular contact email address. What I am doing is runing a C# service in smart as well as pocketpc] I have registered some events like m

How to catch button press in Notification message? takes message as HTML. sn = {0}; sn.pszHTML = TEXT(""); How can I catch button or hyperlink event being tapped? Lisa
Post new topic   Reply to topic    mspocketpc.org Forum Index -> Developers All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group