I am trying to convert a program from VB6 to VB.NET
It interefaced with a seperate program via a dll file.
To start with I have to initise the Dll file by telling it the addressof a function in my script. This is for the feedback from the dll, it runs the function.
This worked fine under vb6, but in VB.NET it keeps throwing up the error -
----------------------------------------------------
An unhandled exception of Type 'System.NullReferenceException' occurred in MessageCentreWaDapi.exe
Additional information: Object reference not set to an instance of an object.
----------------------------------------------------
It seams to work fine until I populate a TextBox
I "think" this is throwing the memory address of the function.
Iv tried to strip this down to the basic's of where its messing up, so if its a little too Vage, I am sorry...
----------------------------------------------------
Delegate Function ProcessAckDataDelegate(ByVal sAckData As String) As Integer
Delegate Function ProcessReceiveDataDelegate(ByVal sAvatar As String, ByVal nDataLen As Integer, ByVal sData As String) As Integer
Delegate Function ProcessGetAllTextDelegate(ByVal sData As String) As Integer
Private Declare Function InitDDE Lib "wadapi.dll" (ByVal sAppName As String, ByVal pfnProcessAckData As ProcessAckDataDelegate, ByVal pfnProcessReceiveData As ProcessReceiveDataDelegate, ByVal pfnProcessGetAllText As ProcessGetAllTextDelegate) As Short
Private Declare Sub DapiGetAllText Lib "wadapi.dll" (ByVal sAppName As String)
'------------------------------------------------------------------------
' ProcessAckData is being called by the DDE whenever the DDE Server sends
' you an ACK code resulting from the previous action you've taken
'------------------------------------------------------------------------
Public Function ProcessAckData(ByVal sAckData As String) As Integer
msgbox("Ack Code Received")
End Function
'------------------------------------------------------------------------
' ProcessReceiveData is being called by the DDE when another application
' sends data to your Plug-In.
'------------------------------------------------------------------------
Public Function ProcessReceiveData(ByVal sAvatar As String, ByVal nDataLen As Integer, ByVal sData As String) As Integer
msgbox("Data Received")
End Function
'------------------------------------------------------------------------
' ProcessReceiveData is being called by the DDE after you called
' DapiGetAllText to capture the text from the WA client.
'------------------------------------------------------------------------
Public Function ProcessGetAllTextData(ByVal sData As String) As Integer
msgbox("Text Received")
End Function
Public Function StartDDE()
InitDDE(VzProgramName, AddressOf ProcessAckData, AddressOf ProcessReceiveData, AddressOf ProcessGetAllTextData)
DapiRegister(VzProgramName)
End Function
Public Sub GetWorldsAwayText()
DapiGetAllText(VzProgramName)
End Sub
----------------------------------------------------
This is driving me nutz cos it works absoultly fine in vb6 and has for years, just doesnt want to convert to vb.net
It interefaced with a seperate program via a dll file.
To start with I have to initise the Dll file by telling it the addressof a function in my script. This is for the feedback from the dll, it runs the function.
This worked fine under vb6, but in VB.NET it keeps throwing up the error -
----------------------------------------------------
An unhandled exception of Type 'System.NullReferenceException' occurred in MessageCentreWaDapi.exe
Additional information: Object reference not set to an instance of an object.
----------------------------------------------------
It seams to work fine until I populate a TextBox
I "think" this is throwing the memory address of the function.
Iv tried to strip this down to the basic's of where its messing up, so if its a little too Vage, I am sorry...
----------------------------------------------------
Delegate Function ProcessAckDataDelegate(ByVal sAckData As String) As Integer
Delegate Function ProcessReceiveDataDelegate(ByVal sAvatar As String, ByVal nDataLen As Integer, ByVal sData As String) As Integer
Delegate Function ProcessGetAllTextDelegate(ByVal sData As String) As Integer
Private Declare Function InitDDE Lib "wadapi.dll" (ByVal sAppName As String, ByVal pfnProcessAckData As ProcessAckDataDelegate, ByVal pfnProcessReceiveData As ProcessReceiveDataDelegate, ByVal pfnProcessGetAllText As ProcessGetAllTextDelegate) As Short
Private Declare Sub DapiGetAllText Lib "wadapi.dll" (ByVal sAppName As String)
'------------------------------------------------------------------------
' ProcessAckData is being called by the DDE whenever the DDE Server sends
' you an ACK code resulting from the previous action you've taken
'------------------------------------------------------------------------
Public Function ProcessAckData(ByVal sAckData As String) As Integer
msgbox("Ack Code Received")
End Function
'------------------------------------------------------------------------
' ProcessReceiveData is being called by the DDE when another application
' sends data to your Plug-In.
'------------------------------------------------------------------------
Public Function ProcessReceiveData(ByVal sAvatar As String, ByVal nDataLen As Integer, ByVal sData As String) As Integer
msgbox("Data Received")
End Function
'------------------------------------------------------------------------
' ProcessReceiveData is being called by the DDE after you called
' DapiGetAllText to capture the text from the WA client.
'------------------------------------------------------------------------
Public Function ProcessGetAllTextData(ByVal sData As String) As Integer
msgbox("Text Received")
End Function
Public Function StartDDE()
InitDDE(VzProgramName, AddressOf ProcessAckData, AddressOf ProcessReceiveData, AddressOf ProcessGetAllTextData)
DapiRegister(VzProgramName)
End Function
Public Sub GetWorldsAwayText()
DapiGetAllText(VzProgramName)
End Sub
----------------------------------------------------
This is driving me nutz cos it works absoultly fine in vb6 and has for years, just doesnt want to convert to vb.net