R
ReinhardH
Hi,
I have to use a cdecl dll (3 party dll). One of the functions needs a
callback as a parameter.
Unfortunately it seems that I'm not able to solve this issue.
What I have done is:
Declare the callback as
Public Delegate Sub CallbackFunction(ByVal s1 As structure1, ByVal s2 as
Structure2)
the real callback is defined as
Private Sub myCallBackFunction(ByVal s1 As structure1, ByVal s2 as
Structure2)
the function which needs the callback as a parameter is declared as
<DllImport("S.dll", CharSet:=CharSet.Auto,
CallingConvention:=CallingConvention.Cdecl)> _
Public Shared Sub Connect(ByVal s1 as structure1, ByVal callbackFunc As
CallbackFunction, ByVal s2 as Structure2)
And I call it
Dim vbs1 As New Structure1
Dim vbs2 As New Structure2
Dim cbf As CallbackFunction
cbf = AddressOf myCallBackFunction
Try
Connect(vbs1, cbf, vbs2)
Catch ex As Exception
end try
But I always get the error Object Reference not set to an instance an object
..
But when I look into the locals window I can't see that either a structure
nor the callback has the value nothing.
It looks ok - every variable seems to have the correct value.
So what am I doing wrong?
Thank you fro your help and sorry for my bad english
Reinhard
I have to use a cdecl dll (3 party dll). One of the functions needs a
callback as a parameter.
Unfortunately it seems that I'm not able to solve this issue.
What I have done is:
Declare the callback as
Public Delegate Sub CallbackFunction(ByVal s1 As structure1, ByVal s2 as
Structure2)
the real callback is defined as
Private Sub myCallBackFunction(ByVal s1 As structure1, ByVal s2 as
Structure2)
the function which needs the callback as a parameter is declared as
<DllImport("S.dll", CharSet:=CharSet.Auto,
CallingConvention:=CallingConvention.Cdecl)> _
Public Shared Sub Connect(ByVal s1 as structure1, ByVal callbackFunc As
CallbackFunction, ByVal s2 as Structure2)
And I call it
Dim vbs1 As New Structure1
Dim vbs2 As New Structure2
Dim cbf As CallbackFunction
cbf = AddressOf myCallBackFunction
Try
Connect(vbs1, cbf, vbs2)
Catch ex As Exception
end try
But I always get the error Object Reference not set to an instance an object
..
But when I look into the locals window I can't see that either a structure
nor the callback has the value nothing.
It looks ok - every variable seems to have the correct value.
So what am I doing wrong?
Thank you fro your help and sorry for my bad english
Reinhard