Home › Forums › Support › Transfer of how a simple class? › Reply To: Transfer of how a simple class?
I check the sample.
It sent a string that receives the console
NetworkComms.SendObject("Message",
CType(targetServerConnectionInfo.RemoteEndPoint, IPEndPoint).Address.ToString(),
CType(targetServerConnectionInfo.RemoteEndPoint, IPEndPoint).Port,
stringToSend)
I want to get my class to send a simple object.
Using VB.net
I created a simple source
But it does not work.
(An error occurred)
here my code
my class..
<ProtoContract> _
Public Class ProtobufCustomObject
<ProtoMember(1)> _
Public Property IntValue() As Integer
Get
Return m_IntValue
End Get
Private Set(value As Integer)
m_IntValue = value
End Set
End Property
Private m_IntValue As Integer
<ProtoMember(2)> _
Public Property StringValue() As String
Get
Return m_StringValue
End Get
Private Set(value As String)
m_StringValue = value
End Set
End Property
Private m_StringValue As String
''' <summary>
''' Private constructor required for protobuf
''' </summary>
Private Sub New()
End Sub
''' <summary>
''' Constructor object for ProtobufCustomObject
''' </summary>
''' <param name="intValue"></param>
''' <param name="stringValue"></param>
Public Sub New(intValue As Integer, stringValue As String)
Me.IntValue = intValue
Me.StringValue = stringValue
End Sub
End Class
Sending. Side.
Form LOAD
`
NetworkComms.AppendGlobalIncomingPacketHandler(Of Byte())(“ArrayByte”, AddressOf PrintIncomingMessage)
NetworkComms.AppendGlobalIncomingPacketHandler(Of String())(“ArrayString”, AddressOf PrintIncomingMessage2)
NetworkComms.AppendGlobalIncomingPacketHandler(Of ProtobufCustomObject)(“CustomObject”, AddressOf 수신객체)
‘ Connection.StartListening(ConnectionType.TCP, New IPEndPoint(IPAddress.Any, 2020), False)
Connection.StartListening(컨넥션타입, New IPEndPoint(IPAddress.Any, 0))
Dim localListeningEndPoints As List(Of EndPoint) = Connection.ExistingLocalListenEndPoints(컨넥션타입)
For Each localEndPoint As IPEndPoint In localListeningEndPoints
Debug.WriteLine(“서버2 {0}:{1}”, localEndPoint.Address, localEndPoint.Port)
Next`
Send Command button
Dim lastServerIPEndPoint As IPEndPoint = Nothing
lastServerIPEndPoint = IPTools.ParseEndPointFromString(Me.TextBox1.Text)
Dim appl As ApplicationLayerProtocolStatus = ApplicationLayerProtocolStatus.Enabled
Dim ConnectionInfo As ConnectionInfo = New ConnectionInfo(lastServerIPEndPoint, appl)
Dim connectionToUse As Connection = TCPConnection.GetConnection(ConnectionInfo)
Dim kkk As ProtobufCustomObject = New ProtobufCustomObject(1111, "2222")
connectionToUse.SendObject("CustomObject", kkk)
err messge…from ExplicitSerializer class..
처리되지 않은 ‘System.ArgumentException’ 형식의 예외가 NetworkCommsDotNet.dll에서 발생했습니다.
추가 정보: objectToSerialize must implement IExplicitlySerialize
so…
Please provide me a simple VB.net samples
It is a simple string, my custom class objects, including a number
It is the server and the client of the window-based
Samples for transmitting and receiving.