473,804 Members | 2,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#-App: Deserialization from different projects.

16 New Member
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.LoadM aps(); 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 1378
Kapps
16 New Member
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.newP layer Player = new MapControl.newP layer();
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
1471
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", "from hongqn.proj2.subpack1 import module2", etc. These projects are developed and maintained and distributed seperately, so I should not make a whole 'hongqn' package with one setup.py. I must write setup.py scripts for each project. I meet a...
5
1577
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 c:\solution c:\solution\project1 c:\solution\project2 ....
8
1217
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 and show the error window. This is normal. (Title of the dialog = Microsoft Development Environment') A second project doesn't do that. It shows another error dialog (the
7
3172
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 inital use of the UserControl component works. However, if the Helper Project is recompiled, the UserControl does not work
7
2315
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 Sub ShowFormB Dim frm as new < ? FormB?? various things I tried here> frm.Show() Me.Close() End Sub
2
1418
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 logs users in with the login controls. Another project in a subfolder (so only accessable by authenticated users) uses methods like Membership.GetUser("john"); Whenever I try this, it just returns a null MembershipUser object. Am I just doing...
2
1084
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 than 1 project. I placed the base forms under one of the project and found that they cannot be inherited by another project in the same solution file. Question: How to place the base forms (in VS2005), so that they can be inherited by all...
2
1974
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 more and more, over the last few years, in C# and ASP.NET. Some web apps, some background services. In our C++ code base, we have a fair number of statically-linked libraries that contain code we share between projects. At this point, in our...
3
1372
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. Also, can work in different projects at the same time. Some projects could be added but role of employees could be specified later on. Employees: Empid,Empcode,Empname (autonumber,text, text) Projects: Projectid,Projectcode,ProjectName (autonumber,...
0
10562
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.