Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Addressof and Dll file

Status
Not open for further replies.

VzHouston

Programmer
May 10, 2006
2
GB
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
 
Which line of code is throwing the error?


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Its not any line of code really,

It crashes when the wadapi.dll tries to communicate back (by running the function in memory)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top