Re: Problem in the calling the dll functions

From: Oleg Starodumov (com-dot-debuginfo-at-oleg)
Date: 01/11/05


Date: Tue, 11 Jan 2005 16:35:39 +0200


> Error Message : Unhandled exception at 0x0008686a in export.exe: 0xC0000005:
> Access violation reading location 0x0008686a.
>

Here are some possible reasons:
1) Buffer overwrite in a function (thus jumping to incorrect address when returning;
    check arrays declared as local variables and make sure that the code does not write
    past their boundaries)
2) Function call through an invalid pointer
3) Heap corruption
4) Some other reasons are possible, but less likely

> what should be the approach to find out the error

Try to step through the code in the debugger, it is very likely
that you will find the problem this way. If you attached the debugger
only after the exception, check the call stack - it can tell what functions
were called recently (though it is possible that the call stack will not be available).

Also, since you write the code, use tracing and insert as many trace statements
into the application and the DLL as possible (at least, trace all function calls).
The trace log will tell you what functions have been executing just before
the problem occurred, therefore you will know where to look for the problem.
You can use OutputDebugString, TRACE, ATLTRACE, or other tracing libraries
(e.g. see CodeGuru.com).

Check that all DLL functions are properly declared, and the declarations
are up-to-date in the DLL and in the client application.
Make sure that the up-to-date version of the DLL is used
(check the location it is loaded from).

If you use VS.NET, make sure that /RTC1 and /GS compiler options are enabled.

If you call functions through pointers, verify all pointers before calling the functions.

If it does not help, there are other approaches that can be applied.

Regards,
Oleg



Relevant Pages

  • Re: Use existing C code in C# application
    ... way is to create a .NET Class Library using Managed C++ and wrap calls to ... "Win32 Project" and select DLL as the type of project. ... create a header file and wrap the exported function declarations as so: ... DllImport in your C# applications in order to call your exported function ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [newbie]Calling eVc4++ dll from .NET application
    ... The OpenNETCF Smart Device Framework, found at www.opennetcf.org, has tons ... of platform invoke (P/Invoke) declarations that you might use as examples. ... > I've developed a very simple dll using eVc4++ ...
    (microsoft.public.windowsce.app.development)
  • Re: convert an MFC application to MFC DLL
    ... This suggests that there are too many global variables. ... All the header files which contain extern ... Once the variables are in the DLL, they cannot be accessed by the main program. ... The whole notion that there is a "single" main.cpp which contains the declarations of the ...
    (microsoft.public.vc.mfc)
  • Re: VB and Weather station
    ... > DLL but untill now witn any succes. ... >> Tim wrote: ... >>> I want to make my own interface for my Davis Avantage Pro 2 Weather ... the correct set of declarations in your VB program. ...
    (comp.lang.basic.visual.misc)
  • Re: lang effort: type conversions
    ... the variation does lead to the occurance that function declarations are ... rat, rational, fixnum, or on heap. ... have this explicit and under control of the programmer for maths reasons ... note, however, for other reasons closures may not be allowed as methods ...
    (comp.lang.misc)