-
July 9th, 2014, 11:30 AM
#1
First Chance Exception CString
Why would the following line of code cause an exception and how can I fix it? This is with Visual Studio 2013 and it is set to use "Multibyte Character Set".
This is a very old program that I was updating.
Both dadir and thepath are type CString.
Prior to this line dadir looks fine when I look at it in the debugger but when I reach this line of code I get
First-chance exception at 0x0FA08EE1 (mfc120d.dll) in GAQUtilities2014.exe: 0xC0000005: Access violation reading location 0xFEFEFFC6.
Verere testudinem! (Fear the turtle)
Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy. -Albert Einstein
Robots are trying to steal my luggage.
-
July 9th, 2014, 11:53 AM
#2
Re: First Chance Exception CString
Did you call somewhere GetBuffer without the following ReleaseBuffer?
Try to set a breakpoint to this line to see where it was called from and when. Then restart the debugging from some earlir point.
Victor Nijegorodov
-
July 10th, 2014, 08:28 AM
#3
Re: First Chance Exception CString
I'm not very experienced with unicode, but IIRC you have to prefix the string constants with "L".
Code:
thepath = dadir + L"\\*.csv";
Does it make any difference?
Nobody cares how it works as long as it works
-
July 10th, 2014, 08:35 AM
#4
Re: First Chance Exception CString
Originally Posted by zerver
I'm not very experienced with unicode, but IIRC you have to prefix the string constants with "L".
Code:
thepath = dadir + L"\\*.csv";
Does it make any difference?
But OP wrote:
Originally Posted by Tom Frohman
... This is with Visual Studio 2013 and it is set to use "Multibyte Character Set".
Victor Nijegorodov
-
July 10th, 2014, 09:00 AM
#5
Re: First Chance Exception CString
Alright, well then use the _T macro anyway just to be sure, and rewrite the code a bit to rule out the possiblilty of corruption...
Code:
CString test = dadir;
test += _T("\\*.csv");
thepath = test;
Nobody cares how it works as long as it works
-
July 10th, 2014, 09:05 AM
#6
Re: First Chance Exception CString
You could have memory corruption elsewhere in the app making it such that it only appears to be failing on the CString line.
As a test, insert some temporary lines of code above the CString line. If the Cstring works at that point, you will know there memory corruption happening earlier.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|