R
Ray Mitchell
I'm trying to do serialization of an object across a
network. I'm getting an error when the client runs that
says: "Cannot find the assembly MyServer,
Version=1.0.1420.18327, Culture=neutral,
PublicKeyToken=null.
at
System.Runtime.Serialization.Formatters.Binary.BinaryAssemb
lyInfo.GetAssembly()"
MyServer is the name of my server project. First, why is
this error occurring and second, is the code below the
correct approach?
Thanks for all your help,
Ray Mitchell
SERVER CODE:
IPAddress ipAdr = Dns.Resolve("localhost").AddressList[0];
TcpListener server = new TcpListener(ipAdr, 10006);
server.Start();
TcpClient client = server.AcceptTcpClient();
BinaryWriter bWriter = new BinaryWriter((Stream)
client.GetStream());
BinaryFormatter bFormatter = new BinaryFormatter();
MyObject obj = new MyObject();
bFormatter.Serialize(bWriter.BaseStream, obj);
CLIENT CODE:
TcpClient client = new TcpClient("localhost", 10006);
BinaryReader bReader = new BinaryReader((Stream)
client.GetStream());
BinaryFormatter bFormatter = new BinaryFormatter();
MyObject obj = new MyObject();
obj = (MyObject)bFormatter.Deserialize(bReader.BaseStream);
THE OBJECT:
[Serializable]
public class MyObject
{
internal int objType;
internal string fname;
internal int length;
}
network. I'm getting an error when the client runs that
says: "Cannot find the assembly MyServer,
Version=1.0.1420.18327, Culture=neutral,
PublicKeyToken=null.
at
System.Runtime.Serialization.Formatters.Binary.BinaryAssemb
lyInfo.GetAssembly()"
MyServer is the name of my server project. First, why is
this error occurring and second, is the code below the
correct approach?
Thanks for all your help,
Ray Mitchell
SERVER CODE:
IPAddress ipAdr = Dns.Resolve("localhost").AddressList[0];
TcpListener server = new TcpListener(ipAdr, 10006);
server.Start();
TcpClient client = server.AcceptTcpClient();
BinaryWriter bWriter = new BinaryWriter((Stream)
client.GetStream());
BinaryFormatter bFormatter = new BinaryFormatter();
MyObject obj = new MyObject();
bFormatter.Serialize(bWriter.BaseStream, obj);
CLIENT CODE:
TcpClient client = new TcpClient("localhost", 10006);
BinaryReader bReader = new BinaryReader((Stream)
client.GetStream());
BinaryFormatter bFormatter = new BinaryFormatter();
MyObject obj = new MyObject();
obj = (MyObject)bFormatter.Deserialize(bReader.BaseStream);
THE OBJECT:
[Serializable]
public class MyObject
{
internal int objType;
internal string fname;
internal int length;
}