0xC0000005 Access Violation MFC42D.DLL Windows XP

Posted on 2006-06-27
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...

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!
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Window placement 17 65
Line meaning 9 77
scoreUp challenge 14 48
Change to event 1 73
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now