|
-
Nov 24th, 2003, 10:25 AM
#1
Thread Starter
Frenzied Member
Object Reference Error
I'm getting the following error
Object Reference not set to an instance of an object
On this line of code
VB Code:
Private Declare Function ImageDirectoryEntryToData Lib "dbghelp.dll" (ByVal pBase As Long, ByVal bMappedAsImage As Long, ByVal DirectoryEntry As Int32, ByRef Size As Long) As Long
Private Structure IMAGE_EXPORT_DIRECTORY
Public Characteristics As Long
Public TimeDateStamp As Long
Public MajorVersion As Int32
Public MinorVersion As Int32
Public lpName As Long
Public Base As Long
Public NumberOfFunctions As Long
Public NumberOfNames As Long
Public lpAddressOfFunctions As Long
Public lpAddressOfNames As Long
Public lpAddressOfNameOrdinals As Long
End Structure
Const IMAGE_DIRECTORY_ENTRY_EXPORT = 0
Private lngBaseAddress As Long
Dim pExportDirectory As Long
Dim lngSize As Long
pExportDirectory = ImageDirectoryEntryToData(lngBaseAddress, 1, IMAGE_DIRECTORY_ENTRY_EXPORT, lngSize)[color=red]<----- This line[/color]
I am creating an application that allows the user to load a .dll file via the OpenFileDialog control. Then they click a button to enumerate the Functions in that dll.
Any ideas why I would be getting this error??? I created this application just fine in VB6 and have made all the necessary modifications to rewrite it in VB.NET, but am getting this error for some reason???
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Nov 24th, 2003, 12:30 PM
#2
A Long in .net is now an Integer. Change the APIs so they return integers, and the structure should probly be ints as well.
The .net equivalent of the integer, is now a short.
An int32 is the same as the .net integer (the old VB6 long).
Of course, it could be something else, but my bets on that.
-
Nov 24th, 2003, 01:38 PM
#3
Thread Starter
Frenzied Member
well, that fixed that problem...now I have another error
System.Argument Exception
"The parameter is incorrect"
VB Code:
Private Declare Function MoveMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Dest As Object, ByRef Src As Object, ByVal Size As Int32) As Int32
Private Structure IMAGE_EXPORT_DIRECTORY
Public Characteristics As Int32
Public TimeDateStamp As Int32
Public MajorVersion As Short
Public MinorVersion As Short
Public lpName As Int32
Public Base As Int32
Public NumberOfFunctions As Int32
Public NumberOfNames As Int32
Public lpAddressOfFunctions As Int32
Public lpAddressOfNames As Int32
Public lpAddressOfNameOrdinals As Int32
End Structure
Dim pExportDirectory As Int32
Dim ExportDirectory As IMAGE_EXPORT_DIRECTORY
MoveMemory(ExportDirectory, pExportDirectory, Len(ExportDirectory)) [color=red]<---- This line [/color]
'The values being pass into the function are:
'ExportDirectory = ProjectName.Form1 + IMAGE_EXPORT_DIRECTORY
'pExportDirectory = 1431884864
'Len(ExportDirectory) = 44
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
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
|