Results 1 to 3 of 3

Thread: Object Reference Error

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    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:
    1. 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
    2.  
    3. Private Structure IMAGE_EXPORT_DIRECTORY
    4.         Public Characteristics As Long
    5.         Public TimeDateStamp As Long
    6.         Public MajorVersion As Int32
    7.         Public MinorVersion As Int32
    8.         Public lpName As Long
    9.         Public Base As Long
    10.         Public NumberOfFunctions As Long
    11.         Public NumberOfNames As Long
    12.         Public lpAddressOfFunctions As Long
    13.         Public lpAddressOfNames As Long
    14.         Public lpAddressOfNameOrdinals As Long
    15.     End Structure
    16.  
    17. Const IMAGE_DIRECTORY_ENTRY_EXPORT = 0
    18. Private lngBaseAddress As Long
    19.  
    20. Dim pExportDirectory As Long
    21. Dim lngSize As Long
    22.  
    23. 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

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    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.

  3. #3

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    well, that fixed that problem...now I have another error
    System.Argument Exception
    "The parameter is incorrect"
    VB Code:
    1. Private Declare Function MoveMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Dest As Object, ByRef Src As Object, ByVal Size As Int32) As Int32
    2.  
    3. Private Structure IMAGE_EXPORT_DIRECTORY
    4.      Public Characteristics As Int32
    5.      Public TimeDateStamp As Int32
    6.      Public MajorVersion As Short
    7.      Public MinorVersion As Short
    8.      Public lpName As Int32
    9.      Public Base As Int32
    10.      Public NumberOfFunctions As Int32
    11.      Public NumberOfNames As Int32
    12.      Public lpAddressOfFunctions As Int32
    13.      Public lpAddressOfNames As Int32
    14.      Public lpAddressOfNameOrdinals As Int32
    15. End Structure
    16.  
    17. Dim pExportDirectory As Int32
    18. Dim ExportDirectory As IMAGE_EXPORT_DIRECTORY
    19.  
    20. MoveMemory(ExportDirectory, pExportDirectory, Len(ExportDirectory)) [color=red]<---- This line [/color]
    21.  
    22. 'The values being pass into the function are:
    23. 'ExportDirectory = ProjectName.Form1 + IMAGE_EXPORT_DIRECTORY
    24. 'pExportDirectory = 1431884864
    25. '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
  •  



Click Here to Expand Forum to Full Width