my code...
ok, well for one, i am using c sharp on one side and visual basic.net 2008 on the other, both .net 3.5 but it really shouldnt matter because they both create the same types of applications, but im not positive if it really matters or not. and i am using microsoft virtual pc 2007, running a windows xp on that, and my main(host) is a windows vista sp1. umm but im running c sharp on my virtual pc, and visual basic 2008 on my vista. but the c-sharp code is this, its in a console application...
vb.net translation, tcplistener)
'that code part was inside of the main class
'this code is outside of everything
<Serializable()> _
Public Class employee
Public name As String = Nothing
Public years As Integer = 0
End Class
Public Shared Sub Main(ByVal args() As String)
Dim mydeserializer As BinaryFormatter = New BinaryFormatter
Dim listenip As IPAddress = IPAddress.Parse("xxx.xxx.x.xxx")
Dim listenport As Integer = Integer.Parse("xxxxx")
Dim locallistener As TcpListener = New TcpListener(listenip, listenport)
locallistener.Start
Dim localtcpclient As TcpClient = locallistener.AcceptTcpClient
Dim mylocalnetstream As NetworkStream = localtcpclient.GetStream
Dim mynetsendedemployee As employee
mynetsendedemployee = CType(mydeserializer.Deserialize(mylocalnetstream),employee)
'line that throws exception listed below
Console.WriteLine("Employee's Name: {0}", mynetsendedemployee.name)
Console.WriteLine("Employee's Years: {0}", mynetsendedemployee.years)
mylocalnetstream.Close
localtcpclient.Close
locallistener.Stop
End Sub
ok thats the code for the tcplistener, im trying to get it to deserialize the class.
but heres the code for the visual basic code for the tcpclient sending the data to the server(tcplistener)
Module Module1
Sub Main()
Dim myemptest As New employee()
Dim myformatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim mytcpclient As New Net.Sockets.TcpClient("xxx.xxx.x.xxx", xxxxx)
Dim mynetstream As Net.Sockets.NetworkStream = mytcpclient.GetStream
myemptest.name = "Joe"
myemptest.years = "14"
myformatter.Serialize(mynetstream, myemptest)
Threading.Thread.Sleep(10000) ' i do this so the stream doesnt close before the data is read _
or unserialized because i dont know if it would throw an exception if the stream is closed before its read.
mynetstream.Close()
mytcpclient.Close()
End Sub
End Module
<Serializable()> Public Class employee
Public name As String = vbNull
Public years As Integer = 0
End Class
and the exception is, (unhandledserializationexception)
' Unable to find assembly 'server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. '
and i know just sending data serialized like that isnt secure enough, but i just want to get the feel of it first, then start securing it, or something. ok plz write back, thanks for your help.