I'm trying to create a
VB wrapper for an exported DLL function. I believe I've set
up everything correctly, but I keep getting this error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where it
originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance
of an object.
My
VB code for the compiled wrapper. For my purposes, test.dll has an exported
function called MyGetString that takes a pointer to a structure:
Imports System.Runtime.InteropServices
< StructLayout( LayoutKind.Sequential, CharSet := CharSet.Ansi )> _
Public Structure MYSTRUCT
Public StrIn As System.String
Public StrOut As System.String
End Structure
Public Class LibWrapper
Declare Function MyGetString Lib "test.dll" _
( <[In], Out> ByVal InOutParams As MYSTRUCT ) As Integer
End Class
VBC Compiler:
vbc.exe /t:library /r:System.dll test.
vb /out:test.dll
My
VB script:
Dim P as MYSTRUCT
Dim Obj as LibWrapper
P = new MYSTRUCT
P.StrIn = "Test"
Obj = new LibWrapper
Obj.MyGetString(P)
The error is flagged on this line:
>>Obj.MyGetString(P)
Doesn't the new operator create an instance to an object? If so, why
isn't this working?