Solved

Access Violation 0xc0000005

Posted on 2004-10-05
4
226 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MSVCR80.dll crash 2 134
java inner class, for the sole use of parameter passing 21 76
C++ question 3 61
Beginner to Unreal Engine 4 5 57
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

919 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

14 Experts available now in Live!

Get 1:1 Help Now