Solved

Access Violation 0xc0000005

Posted on 2004-10-05
4
234 Views
Last Modified: 2010-04-01
I have a small console EXE and DLL, both compiled with the single-threaded debug version of the runtime library. All classes in the DLL are exported and I link to the import library in the EXE. However, I get an application failed to initialize error (0xc0000005) when trying to run the EXE in the IDE or from the command line and the program fails to run. I know it's probably something simple I'm doing wrong or missing, but how do I get around this so I can see that my EXE is actually using the DLL? Thanks.
0
Comment
Question by:davev
4 Comments
 
LVL 8

Expert Comment

by:mxjijo
ID: 12232949

run in debug mode (F5). It will stop at the point where it crashes
0
 

Expert Comment

by:Scobar
ID: 12246328
Try checking that your dll exports the correct functions, etc using a program like Dependency Walker.
http://www.dependencywalker.com/ 

Open your .exe program with this and check the functions against your .DLL.
0
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 50 total points
ID: 12248727
Set a breakpoint to the begin of the executable. When stopped at break point open menu Debug - Exceptions ... . Locate "access violation" in the exception list below, hilite it and check "Stop Always" radio button. Then run the prog to the crash.

When stopped in Debugger, check the Call Stack Window (if not already shown, right-click to an empty spot somewhere in the menu area of Visual Studio and check "Call Stack"). Check call hierarchy top down til you see any function you've written. Open source and you spotted the line of your code that caused the crash. "Access violation" most likely is a call to a NULL pointer, an uninitialized pointer or a pointer already deleted. It could also be a strcpy or a memcpy where the destination buffer is less than the sopurce buffer. When calling a DLL you couldn't delete a pointer created in the DLL and viceversa. Both might lead to an access violation.

Regards, Alex
 
0

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

713 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