Conversion from VB6 to VB.NET



Hi,

My conversion seems from VB6 to VB.Net of an interface to an API seem to
have gone OK, but when I look at the output from the Debug.Print("Active
server is " & xmlServerActive) statement, xmlServerActive only contains one
character(the first one). I suspect it is being truncated. I am pretty much a
novice at this sort of thing so any advice would be welcome.

Here is the old VB6 code:
Listening for Servers and System Status using VB
‘ Declare the functions
Public Declare Function RCA_listenForServersBstr Lib "clientapi.dll" _
(ByVal serverActiveCallback As Long, _
ByVal serverShutdownCallback As Long) As Integer
Public Declare Function RCA_listenForSystemStatusBstr Lib "clientapi.dll" _
(ByVal systemStatusCallback As Long, _
ByVal clusterCreatedCallback As Long, _
ByVal clusterDeletedCallback As Long, _
ByVal systemExceptionCallback As Long) As Integer
‘ Declare callback functions
Public Function serverActiveCallback(ByVal xmlServerActive As String) As Long
Debug.Print "Active server is " & xmlServerActive
End Function
Public Function serverShutdownCallback(ByVal server As String) As Long
Debug.Print "Shutdown server is " & server
End Function
Public Function systemExceptionCallback(ByVal error As String) As Long
MsgBox "Error : " & error
End Function
Public Function systemStatusCallback(ByVal systemStatus As String) As Long
Debug.Print "System status is " & systemStatus
End Function
Public Function clusterCreatedCallback(ByVal cluster As String) As Long
Debug.Print "Created cluster is " & cluster
End Function
Public Function clusterDeletedCallback(ByVal cluster As String) As Long
Debug.Print "Deleted cluster is " & cluster
End Function
‘ Set up to listen for servers
ret = RCA_listenForServersBstr(AddressOf serverActiveCallback, _
AddressOf serverShutdownCallback)
‘ Set up to listen for system status
ret = RCA_listenForSystemStatusBstr(AddressOf systemStatusCallback, _
AddressOf clusterCreatedCallback, _
AddressOf clusterDeletedCallback, _
AddressOf systemExceptionCallback)


The new VB.NET (It has some other pieces I have added)
Option Strict Off
Option Explicit On
Module RimagesAPI

Public Structure RCA_production_order_description
<VBFixedString(128),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=128)> Public orderId() As Char ' This field cannot be NULL
<VBFixedString(128),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=128)> Public clientId() As Char ' This field is optional and can
be NULL
<VBFixedString(128),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=128)> Public originator() As Char ' This field is optional and can
be NULL
<VBFixedString(128),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=128)> Public targetCluster() As Char ' This field cannot be NULL
<VBFixedString(128),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=128)> Public targetServer() As Char ' This field is optional, if
null then any
<VBFixedString(32),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=32)> Public priority() As Char ' Default for this field is
PRIORITY_MEDIUM
<VBFixedString(32),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=32)> Public action() As Char ' Default for this field is
ACTION_RECORD
<VBFixedString(32),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=32)> Public mediaType() As Char ' Default for this field is MT_CDR
<VBFixedString(32),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=32)> Public mediaSize() As Char ' Default for this field is MS_120
<VBFixedString(32),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=32)> Public targetLine() As Char ' Default for this field is TL_ANY
<VBFixedString(32),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=32)> Public copies() As Char ' Default for this field is 1
<VBFixedString(32),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=32)> Public inOutInputBin() As Char ' Default for this field is
IOB_ANY
<VBFixedString(32),
System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,
SizeConst:=32)> Public outputMailslot() As Char ' Default for this field is 0
End Structure

Public Declare Function RCA_connect Lib "clientapi.dll" (ByVal clientId As
String) As Short
Public Declare Function RCA_connectEx Lib "clientapi.dll" (ByVal clientId
As String, ByVal host As String, ByVal port As String) As Short
Public Declare Function RCA_listenForServersBstr Lib "clientapi.dll"
(ByVal serverActiveCallback As serverActiveCallbackDelegate, ByVal
serverShutdownCallback As serverShutdownCallbackDelegate) As Short
Public Declare Function RCA_listenForSystemStatusBstr Lib
"clientapi.dll" (ByVal systemStatusCallback As systemStatusCallbackDelegate,
ByVal clusterCreatedCallback As clusterCreatedCallbackDelegate, ByVal
clusterDeletedCallback As clusterDeletedCallbackDelegate, ByVal
systemExceptionCallback As systemExceptionCallbackDelegate) As Short
Public Declare Function RCA_submitProductionOrderBstr Lib
"clientapi.dll" (ByRef orderDesc As RCA_production_order_description, ByVal
xmlOrder As String, ByVal orderStatusCallback As orderStatusCallbackDelegate)
As Short
Public Declare Function RCA_cancelProductionOrder Lib "clientapi.dll"
(ByRef orderDesc As RCA_production_order_description, ByVal abortCurrent As
Boolean) As Short
Public Declare Function RCA_stopListeningForProductionOrder Lib
"clientapi.dll" (ByRef orderDesc As RCA_production_order_description) As Short


Delegate Function serverActiveCallbackDelegate(ByVal xmlServerActive As
String) As Integer
Public Function serverActiveCallback(ByVal xmlServerActive As String) As
Integer
Debug.Print("Active server is " & xmlServerActive)
End Function
Delegate Function serverShutdownCallbackDelegate(ByVal server As String)
As Integer
Public Function serverShutdownCallback(ByVal server As String) As Integer
Debug.Print("Shutdown server is " & server)
End Function
Delegate Function systemExceptionCallbackDelegate(ByVal wError As
String) As Integer
Public Function systemExceptionCallback(ByVal wError As String) As Integer
MsgBox("Error : " & wError)
End Function
Delegate Function systemStatusCallbackDelegate(ByVal systemStatus As
String) As Integer
Public Function systemStatusCallback(ByVal systemStatus As String) As
Integer
Debug.Print("System status is " & systemStatus)
End Function
Delegate Function clusterCreatedCallbackDelegate(ByVal cluster As
String) As Integer
Public Function clusterCreatedCallback(ByVal cluster As String) As Integer
Debug.Print("Created cluster is " & cluster)
End Function
Delegate Function clusterDeletedCallbackDelegate(ByVal cluster As
String) As Integer
Public Function clusterDeletedCallback(ByVal cluster As String) As Integer
Debug.Print("Deleted cluster is " & cluster)
End Function
Delegate Function orderStatusCallbackDelegate(ByVal orderStatus As
String) As Integer
Public Function orderStatusCallback(ByVal orderStatus As String) As
Integer
On Error Resume Next
Debug.Print(orderStatus)
orderStatusCallback = 0
End Function

.



Relevant Pages

  • Re: Conversion from VB6 to VB.NET
    ... Public Function serverActiveCallback(ByVal xmlServerActive As String) As Long ... Debug.Print "Active server is " & xmlServerActive ... Public Function clusterCreatedCallback(ByVal cluster As String) As Long ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How to discover Exchange Server is an EVS (clustered)?
    ... Determining If the Specified Server Is a Clustered Server ... ' Exchange Management Library, Microsoft Cluster Service Automation Classes, ... Dim szConnString As String ... Set objContainer = objLdap.OpenDSObject(szConnString, _ ...
    (microsoft.public.exchange.development)
  • Re: NLB Cluster - Ping fails or long time to reply from outside local subnet - SOLVED
    ... Windows Server 2008 Readiness Team ... cluster on a separate DLink card in multicast mode. ... I thought that the litmus test was that the router functions fine ... member of the NLB cluster, setup NLB on it, plug the NICs ...
    (microsoft.public.windows.server.clustering)
  • Re: NLB Cluster - Ping fails or long time to reply from outside local subnet - SOLVED
    ... Once again, ARP is an RFC standard, if you are having to make static entries in unicast mode, then your network device is not in compliance. ... Windows Server 2008 Readiness Team ... I was feeling nervous about our teaming-capable adapter as I read it might be sending out heartbeats, so I disabled it AND configured the cluster on a separate DLink card in multicast mode. ... I thought that the litmus test was that the router functions fine when no NLB is installed, but when it is, things start going screwy. ...
    (microsoft.public.windows.server.clustering)
  • Re: NLB Cluster - Ping fails or long time to reply from outside local subnet - SOLVED
    ... One server with no cluster configured - all works ok. ... When static ARP mappings are added all works ok. ... I thought that the litmus test was that the router functions fine when ...
    (microsoft.public.windows.server.clustering)