Solved

Access Violation 0xc0000005

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

760 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

22 Experts available now in Live!

Get 1:1 Help Now