473,383 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Network Serialization

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.Bin aryAssemb
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.BaseStrea m);

THE OBJECT:
[Serializable]
public class MyObject
{
internal int objType;
internal string fname;
internal int length;
}

Nov 15 '05 #1
1 2839
Hi Ray,
MyObject class have to be implemented in a separate assembly, which you
have to reference both on server and on client.

More info you can find in the tread "Deserializing in a different
assembly... how to?" 2 hour ago in the same group

Sunny
In article <01****************************@phx.gbl>,
an*******@discussions.microsoft.com says...
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.Bin aryAssemb
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.BaseStrea m);

THE OBJECT:
[Serializable]
public class MyObject
{
internal int objType;
internal string fname;
internal int length;
}

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Aaron Clamage | last post by:
Hi, I'm not sure that if this is the right forum, but any help would be greatly appreciated. I am porting some java serialization code to c# and I can't figure out the correct way to do it. ...
3
by: Alexander | last post by:
When i store rule on PC with .NET.SP1 i cant restore them from PC without SP1. An i get this Error: System.Runtime.Serialization.SerializationException: Possible Version mismatch. Type...
8
by: rawCoder | last post by:
Hi All, I need some advanced samples or references for passing custom objects over the network using sockets. Without using Remoting what are other options in .NET Framework for this binary...
2
by: Ricardo Luceac | last post by:
Hi... I'm new to c# network programing, and I only find a way to send plain text over the network, but I need to send an object... Does someone know how do I send this object??? s...
2
by: Mohammad-Reza | last post by:
Hi I want to know is there any way to send structures instance to another computer through the network with sockets? When Send() method only accept byte, How can I send them to the network? ...
3
by: M. Simioni | last post by:
Hi, the scenario should be like this: I have a "Server" application, and a UserControl running on an asp.net page. The UserControl sends a SQL Query string via UDP to the Server (after some sort...
4
by: Chandra | last post by:
Hi all, I have a doubt. If I have 2 structures and one is parent of other , ie the child structure is present in the parent one . And if the child structure is declared as dynamic array in the...
1
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
2
by: mkvenkit.vc | last post by:
Hello, I hope this is the right place to post a question on Boost. If not, please let me know where I can post this message and I will do so. I am having a strange problem with std::string as...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.