[Last Call] Learn how to a build a cloud-first strategyRegister Now


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 http://support.microsoft.com/support/kb/articles/q105/6/75.asp 

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...
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

830 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