473,388 Members | 1,277 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,388 software developers and data experts.

C#-App: Deserialization from different projects.

16
Hi,

I was wondering how I would go about deserializing a file that was serialized from a different project. I've tried a couple things, but I can't really seem to figure it out. When looking it up, it seemed like it would be solved by just including a class project that did the actual serializing and deserializing, but when I tried this, I still couldn't get it to work. I created a DLL that was referenced by both of my projects, the server and the client, and the DLL does both the Serialization and Deserialization, and returns the value through a function:
Expand|Select|Wrap|Line Numbers
  1. public ArrayList LoadMaps() {
  2.     try {
  3.        bOp.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
  4.        if(File.Exists(MapPath)) {
  5.             fin = File.OpenRead(MapPath);
  6.             MapLoad = (ArrayList)bOp.Deserialize(fin);
  7.             fin.Close();
  8.        }
  9.        return MapLoad;
  10.         } catch(Exception Ex) {
  11.             Console.WriteLine(Ex.Message);
  12.             return null;
  13.         }
  14.     }
  15. }
  16.  
The server includes the level editor, which would create the maps. Maps is an Arraylist with each map, which includes an int32 for X/Y location, as well as a custom class for each square on the map. On connecting, the client messages the server the bytelength of the Maps.dat file, if the server says it's valid, it loads the Maps.dat file through a function that essentially is Maps = MapLoader.LoadMaps(); which is the same as the servers. The server saves it just like most basic serialization functions:
Expand|Select|Wrap|Line Numbers
  1. public void SaveMaps(ArrayList MapArray) {
  2.     fout = File.Create(MapPath);
  3.     bOp.Serialize(fout, MapArray);
  4.     fout.Close();
  5. }

The result is the error:
Unable to find assembly 'MultiWinsock Server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

From what I understand, the error resulting is due to the assembly information of the writing client and the reading client being different, causing the deserialization to fail, but I'm not exactly sure how I would go about solving this. I've tried a few different methods, such as just having each project load the function itself, having the DLL do it (as above), and putting all the project (Server, Client, DLL) in the same solution, but I couldn't figure out an answer. I'm still quite new to C# as you can probably tell, and so I'm not sure on how to go about this. Note that the server can save and load the maps it creates without any problems at all.

Any help would be appreciated.
Aug 6 '08 #1
1 1352
Kapps
16
I solved my problem. :)

Although I had the DLL do the actual saving and loading, when I was referencing the classes (newBoard, newSquare, newPlayer), I was referencing them directly from the project itself, rather than from the DLL.
Eg)
newPlayer Player = new newPlayer(); instead of
MapControl.newPlayer Player = new MapControl.newPlayer();
If anyone else has this problem, you can either find and replace all instances of your class with the reference from your class library, or possibly just add using <classname> to your file.
Aug 6 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Qiangning Hong | last post by:
To avoid namespace confliction with other Python packages, I want all my projects to be put into a specific namespace, e.g. 'hongqn' package, so that I can use "from hongqn.proj1 import module1",...
5
by: davidw | last post by:
I am using microsoft development enviroment 2003. I created a solution, and have some projects, I put the root dir as my IIS home, and each project has their own directory, so it is like ...
8
by: Peter van der Veen | last post by:
Hi I've something strange. There is a different when an error occurs in 2 differen project/solutions. In one project when a get an error the debugger stops at the line which causes the error...
7
by: crowl | last post by:
VS.2003, .NET Framework 1.1, C# My goal: Creating a dll (helper.dll) which contains some UserControls and some other helpful classes in order to use it in other projects. Symtoms: The...
7
by: MikeB | last post by:
Me again. Is it possible to have two projects in a solution (ProjA and ProjB) and have Form1 in ProjA do a .Show() for Form2 in ProjB? I tried the following, but I get a problem with the reference...
2
by: brown | last post by:
Is it possible to access the authenticated user data using the Membership and MembershipUser classes from an asp.net 2.0 project that doesn't contain the login controls? For example, one project...
2
by: Benson | last post by:
I construct some base forms so that we can inherit from them in coding different types of programs (eg. Master program, Inquiry program). I know under a solution (*.sln) in VS2005, we can have more...
2
by: Jeff Dege | last post by:
I'm working with a group that's been doing C++ coding for quite a long time, now, and in that environment we've pretty much worked out development practices that serve us well. We've been doing...
3
by: samvb | last post by:
Hi, I have this database based on this logic: There are projects in a company. In each project, different employees different roles. One employee could have different roles in a single project....
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.