-
November 11th, 2003, 11:30 AM
#1
Help: about Access Violation
I have a DLL to be used under Visual Basic, and the DLL was done in C(using Visual C++). When I compile the project in Visual Basic, it works. But after I made a .EXE file in VB and ran it. The system said: "Unhandled exception in *.exe(*.Dll): 0xC0000005: Access Violation. " And it was the same when I debugged it in Visual C++(6.0) environment. Do you have any idea?
Thank you.
-
November 11th, 2003, 11:32 AM
#2
Just see what causes that crash. It may be an uninitialized pointer.
Snakekaa
Move like a snake, think like a snake, be a snake !!!
-
November 11th, 2003, 11:36 AM
#3
I work mainly with C++. Under Visual C++, a project must support dynamic linking for the application to use DLL.
Kuphryn
-
November 11th, 2003, 11:43 AM
#4
Run VB under the C++ debugger. If you are running your VB application against the debug version of you dll then you can trace right into the access violation.
GL
-
November 11th, 2003, 12:44 PM
#5
I execute the EXE file, the application loads, and then I klick a button on the interface(Dialogbox), and it should do something(implemented in DLL), but at this moment, the error occurs.
What's more, I work under Windows 98.
Thank you.
-
November 11th, 2003, 06:30 PM
#6
What do you mean when you say "it was the same when I debugged it in Visual C++(6.0) environment". If The access Violation happened in debug mode, you can pinpoint exactly what goes wrong. If it only happened in release version, use the following step to turn on debug for release, and debug into it see what went wrong:
How to turn debug on for Release version:
a) For the release build, go to "Project | settings | C/C++" and make sure theat the "General" Category is selected.
b) For "debug info", choose "Program Database" instead of "None".
c) Turn off the optimizations for now.
d) Go to the "Link" tab and check "Generate Debug Info".
e) Rebuil the release mode app.
-Ray
-
November 12th, 2003, 08:01 AM
#7
Well, when I debug the DLL in VC++, it stops with the error report I mentioned when the programm runs into the line: "100090E6 call @ILT+195(checkparam_4_Margin) (100010c8)", and when I click 'OK' to close the error dialog box, the arrow points to the line: "10004B51 mov byte ptr [ecx+eax],0FFh", and can not run further.
*The 'checkparam_4_Margin' is a function in the DLL, but not an exported one.
*I have tried to leave the 'checkparam_4_Margin' out, but it still stops somewhere like: '
1000908D call @ILT+195(psResult) (100010c8)' . The 'psResult' is also a function in the DLL, but an exported one and called in VB.
*Then I left the 'psResult' out of the code, the error still happed in somewhere else.
I don't know how to understand the lines in the debug environment. And I don't know what to do next.
Thank you for your help.
-
November 12th, 2003, 08:11 AM
#8
I suggest you try tmecham's suggestion:
Originally posted by tmecham
Run VB under the C++ debugger. If you are running your VB application against the debug version of you dll then you can trace right into the access violation.
GL
Thought for the day/week/month/year:
Windows System Error 4006:
Replication with a nonconfigured partner is not allowed.
-
November 13th, 2003, 05:50 AM
#9
I have found the problem!
The reason is: The VB calls one function in DLL, and the parameters are defined as integer in DLL, of course I defined these parameters as Integer in VB too. But this is the case. When I change them into Long(Integer), the error never occours.
But I still confused with the problem: The integer has 2 bytes, and a range from -32,768 to 32,767. The values I assign to the parameters are 640 in maxinum, it should have no overflow. And the Long in VB has 4 bytes, of course.
Does anyone know why?
-
November 13th, 2003, 07:53 AM
#10
Originally posted by wind0965
I have found the problem!
The reason is: The VB calls one function in DLL, and the parameters are defined as integer in DLL, of course I defined these parameters as Integer in VB too. But this is the case. When I change them into Long(Integer), the error never occours.
But I still confused with the problem: The integer has 2 bytes, and a range from -32,768 to 32,767. The values I assign to the parameters are 640 in maxinum, it should have no overflow. And the Long in VB has 4 bytes, of course.
Does anyone know why?
In VC++, an int is 4 bytes. In VB6, an int is 2 bytes. Regardless of the values held by a variable of type int, those are the memory requirements of that type. VB interpreted the int as 2 bytes, and VC++ was "reading" 4 bytes, to get the value. Change your VB function declaration to indicate that the param is a Long (4 bytes), or change your VC++ function to take a short (2 bytes).
Thought for the day/week/month/year:
Windows System Error 4006:
Replication with a nonconfigured partner is not allowed.
-
May 17th, 2004, 12:47 AM
#11
Access violation
I am supposed to migrate a second-party code written in C++(using VC++) from Windows NT server to Windows 2003 server.
The migration procedure is standard and there doesn't seem to be any problem in the migration part. In fact the program runs fine with one set of parameters.
However, when i run the program with another parameter, it crashes giving the followng error:
The instruction at "0x00336777" referenced memory at "0x0000000c". The memory could not be "read".
Click on OK to terminate the program
Click on CANCEL to debug the program.
When i cancel to debug it, debugging instantly stops giving the following error:
Unhandled Exception in MYPROGRAM.exe(third_party_dll.dll):0x00000005. Access Violation.
I have examined and found that when i give this particular parameter, this code tries to execute a certain function which is written inside a dll(and declared in the corresponding header) . As soon as it tries to execute this function, the program crashes with the above mentioned errors. I do not have access to read the dll since it has been provided by a third party.
I can only read the declaration of this function in the header file. This function was executing fine before the migration with its older version of dll. I have not made any changes in the code during migration.
What can be the reasons and solution to this problem?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|