Improve company productivity with a Business Account.Sign Up


0xC0000005 Access Violation MFC42D.DLL Windows XP

Posted on 2006-06-27
Medium Priority
Last Modified: 2013-11-20

I've an application that runs very well in W2K (not tested in prior versions) but when I try tu run it in WXP it just crash. I don't get any error, just crash. When debugging, I get this:

First-chance exception in ctsmgt.exe (MFC42D.DLL): 0xC0000005: Access Violation.

I've read a lot on how to try to overcome this. Some say to put try/catch blocks, some others just to ignore the exception. I've tried both but it keeps crashing.

I'm really desperate and stuck here, I don't know what to do. Any advice will be greatly, greatly appreciated.

Question by:ObiRenoKenobi
  • 3
  • 2
  • 2
  • +3
LVL 22

Expert Comment

ID: 16998725
>>I've read a lot on how to try to overcome this. Some say to put try/catch blocks, some others just to ignore the exception

What functions are on the call stack when the exception is raised ? Also what is the version of mfco42d.dll ?

You can try to reapply the latest service pack for VC.

LVL 22

Expert Comment

ID: 16998830
Are you running your application on Win XP-SP2 (Service Pack 2 ) ? IF SO THEN also check one more thing to test if MFC42.dll causing the problem..
Copy mfc42.dll from system32 from 'NON SP2 XP' machine to your applications executable directory. If you wish to debug you I believe the file is mfc42D.dll you will need to copy to your debug directory and check your application .

LVL 86

Expert Comment

ID: 17002945
>>First-chance exception in ctsmgt.exe (MFC42D.DLL): 0xC0000005: Access Violation.

'First-chance exception in xxx...' just means that a function from within the 'xxx' caused an access-violation exception that was handled successfully inside the SEH frame that was active when the exception occurred. You can think of it being the same as if you use code like this:

long l;

__try // set up current SEH frame
CopyMemory ( &l, 0, sizeof ( long)); // read from 0x00000000
__except( EXCEPTION_EXECUTE_HANDLER) // handler for current frame
puts ( "We knew that this would go wrong...");

So let's hope that the MS progrmmer knew what they were doing ;-)

(Additional info: MS KB Article Q105675)

The article can be found at 

A first chance exception is called so as it is passed to a debugger before the application 'sees' it. This is done by sending a 'EXCEPTION_DEBUG_EVENT' to the debugger, which can now decide whether it is passed to the apllication to handle it or 'ignore' it (e.g. like an 'EXCEPTION_BREAKPOINT' aka 'int 3'). If the exception isn't handled, it becomes a '2nd chance' exception, the debugger 'sees' it the 2nd time and will usually terminate the program (without using a debugger, these exceptions end up at 'UnhandledExceptionFilter()' which will also signal the exception to the user with one of these 'nice' message boxes and terminate the program, also...)

In short: This message is only generated by a debugger & you can safely ignore it...
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 17004208
I'm looking for a WinXP NO SP2 MFC42D.DLL but can't found one. I tired to use one from W2K but was not a good idea hehehe.

As for the other comment, I read that of ignoring the debug error and just run it in release mode, but, my application crashes also in release, and no error is giving to me. So I think I may not be able just to ignore it :(

Author Comment

ID: 17005879
Hi again!

I've returned with more information. The problems seems to arise when a call to _AFX_INLINE CStringData* CString::GetData() const
is made. It's a bit strange, because of this: I've a function that calls the
void CString::FormatV(LPCTSTR lpszFormat, va_list argList) from STREX.CPP, this in turn, calls GetBuffer(nMaxLen), the funny thing here, is that those functions are called several times, and always, de GetBuffer function goes to VSPRINTF.C, every single time it goes there EXCEPT when is crashing, a debug breakpoint was established in that function call, and whenever it enter (using F11 key) it goes to VSPRINTF.C, but when I enter the function just a step before it crashes, it goes to LPTSTR CString::GetBuffer(int nMinBufLength) and in that function, in the first IF (when it try to do GetData()-nRefs) it goes to _AFX_INLINE CStringData* CString::GetData() const, and right there is when the exception arises and the program crashes.

One thing that I must mention, I don't know if it is important, but nonetheless I will tell you. In all the cases when GetBuffer is called, except when it crashes, the variable m_pchData have something, but... when it's about to crash, the debuger says:
m_pchData      CXX0030: Error: expression cannot be evaluated
and following the debug, when it enters the_AFX_INLINE CStringData* CString::GetData() const, it says:
m_pchData      CXX0069: Error: variable needs stack frame

I don't know why this is, nor if it is important o have anything to do with my problem, but I write down here for your information.

Any new ideas? Thanks!
LVL 11

Expert Comment

ID: 17052473
Very wild guess - have you had a .net update recently i.e. it came around November/December last year but you've only just updated your system with it?  Also, is your system set up for .net 1.1 or .net 2.0 or neither?

Expert Comment

ID: 17084429
Hey ObiRenoKenobi ,

I'm having the same issue as well. Did you resolve it? If so, how?

Thanks a ton.

Author Comment

ID: 17086481
Hi! Sorry for posting till now. I resolved the issue but it was not on the code. The problem was that we were trying to use the application with an Oracle 8i lib, but trying to connect with an Oracle 9i!!! When we switched to Oracle 8i, all started to work... a difficult to track problem, but a silly one.

Thanks to all for your help!

Expert Comment

ID: 17092816
Hey ObiRenoKenobi,

Kindly tell me which oracle 9i lib file to use?


Accepted Solution

CetusMOD earned 0 total points
ID: 17371183
PAQed with points refunded (500)

Community Support Moderator

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A query can call a function, and a function can call Excel, even though we are in Access. This is Part 2, and steps you through the VBA that "wraps" Excel functionality so we can use its worksheet functions in Access. The declaration statement de…

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question