Click here to Skip to main content
15,886,362 members
Everything / Serialization

Serialization

serialization

Great Reads

by Alex Pumpet
A simple program for comparing table data from two sources - SQL databases, Excel, CSV or XML-files
by Massimo Fabiano
I know that "returning DataSets from WebServices is the spawn of Satan" but...
by Sheshnath Kumar
This article will find out a solution to serialize/deserialize object by reference at server and client, also will serialize/deserialize objects having circular references.
by bk192077
I would like to define a C++ structure, pass the person instance to the mapping method along with JSON data, then use the filled structure. Or vice versa, get Person as JSON. StructMapping is trying to solve these problems.

Latest Articles

by bk192077
I would like to define a C++ structure, pass the person instance to the mapping method along with JSON data, then use the filled structure. Or vice versa, get Person as JSON. StructMapping is trying to solve these problems.
by Michael Sydney Balloni
The world is JSON-in, JSON-out, but perhaps we can do better in some situations with our old friend CSV
by honey the codewitch
Creating an application that can run once, but then accept command line args from subsequent runs
by QxOrm
QxOrm C++ library: Persistence (based on QtSql Qt library) - Serialization (based on boost::serialization library) - Reflection (introspection)

All Articles

Sort by Score

Serialization 

20 Mar 2018 by Alex Pumpet
A simple program for comparing table data from two sources - SQL databases, Excel, CSV or XML-files
28 Sep 2016 by Massimo Fabiano
I know that "returning DataSets from WebServices is the spawn of Satan" but...
31 Aug 2016 by Sheshnath Kumar
This article will find out a solution to serialize/deserialize object by reference at server and client, also will serialize/deserialize objects having circular references.
1 May 2022 by bk192077
I would like to define a C++ structure, pass the person instance to the mapping method along with JSON data, then use the filled structure. Or vice versa, get Person as JSON. StructMapping is trying to solve these problems.
18 May 2016 by Simon Bridge
Describes how to write your own SerializationBinder to allow serialization across assemblies
5 Dec 2015 by Denis Murashov
In the article I describe the possibilities of standard Delphi DFM-serialization mechanism. I start from the basics and then try to cover more complex situations.
18 Jan 2018 by Dirk Bahle
Tips & Tricks on de/serializing Tree View based content with XML
1 Apr 2013 by Sergey Alexandrovich Kryukov
Don't serialize/deserialize controls. Have a data layer, serialize the data and use it to populate the controls, and update. —SA
21 Oct 2013 by Rob Philpott
Streams hold the answer. The way you are doing at the moment you serialize the whole thing into a MemoryStream and then convert that to a byte array.If you want to send the thing via Tcp, drop the MemoryStream and use the NetworkStream you get when you connect directly. There will be some...
20 Jun 2014 by phil.o
Enumerations are serializable by nature (they are constant integer values). You don't have to bother :)Why not just making a simple trivial test to check it?Kind regards.
10 Jan 2016 by OriginalGriff
Because you are doing something extremely silly.You are trying to present 80,000 rows containing at least 90 columns each of data to your user, and expecting him to find the row he is interested in by scrolling and hoping.Think about it: you you want to revisit a web site if it did that to...
3 Dec 2018 by replaysMike
How to binary serialize your classes without having to modify them
2 Apr 2014 by Sergey Alexandrovich Kryukov
I would advice considering boost serialization: http://www.boost.org/doc/libs/1_55_0/libs/serialization/doc/index.html[^].This is the open source, of course. Please see also:http://en.wikipedia.org/wiki/Boost_%28C%2B%2B_libraries%29[^],http://www.boost.org/[^].—SA
5 Apr 2014 by Homero Rivera
I hate to say it, but the cast on client side...Student s = (Student)bin.Deserialize(receive.BaseStream);will never work, not like that at least.Why? For security reasons... How about someone forging a "Server.Student" and send that to your Client with malicious data?If your...
19 Jun 2014 by Maciej Los
If you want to know the way you can serialize and deserialize custom class collection, this tip is for you.
13 May 2015 by Jalal Ali
A guide on sockets, and how to send objects across them
26 Jan 2016 by infal
How to write / read multidimensional arrays to/from BinaryWriter/BinaryReader or other stream using UnmanagedMemoryStream
17 Jul 2019 by OriginalGriff
JSON does not serialize fields - it only serialises properties, so MemberSerialization.OptIn will make no difference. Change your class: public class Class1 { public bool flag { get; set; } public bool flag2 { get; set; } public Class1() { ...
27 Aug 2019 by Richard Deeming
The problem seems to be that you don't have a wrapping element, so the array attributes are ignored. If you had: then your code would work. Without the wrapping element, it looks like...
2 Feb 2023 by Dave Kreskowiak
First, storing images in the database as anything other than binary is just going to make the image data quite a bit larger than if you just stored the bytes in a binary field, especially using base-64 encoding. Next, wrapping all that in a json...
12 Jul 2012 by DaveyM69
Your TopSurfDescriptor class is serializing the IntPtr as that is what it holds.You would need to retrieve the data at the memory address and do customer serialization/deserialization if you wish to save/load it this way.
18 Jul 2012 by StianSandberg
By default the Font is not XML Serializable since it doesn't have a default (empty) constructor. You can create your own class holding the properties of the font that you need, and serialize that class..fex:public class SerializableFont{ public string FontFamily { get; set; } ...
28 Sep 2012 by fjdiewornncalwe
How is this for an answer: Clicky[^]
1 Oct 2012 by L Viljoen
I see your issue.Your byte array is internal make it publicpublic byte[] FPTemplates { get; set; }Try giving this a Go I see you are converting your string to utf8 and then ascii in your serialisers/// /// Serialize an object into an XML...
5 Oct 2012 by Bryan Lyman
Generic list wrapper that returns a smaller strongly typed sub-list which modifies the parent-list when changed, without using events
10 Jan 2013 by Dhiraj V
Hi,I have a requirement in which i want to serialize various properties like System.Windows.FontWeight,FontStretch and other such structs with the help of JavaScriptSerializer.But it is giving empty json value of above properties on serializing the object having struct data type...
5 Jun 2013 by lukeer
You will have to handle the (de)serialization of Model3DGroup yourself.Create a [Serializable]-decorated class that derives from Model3DGroup and implements the ISerializable interface[^]. If all goes well, you should be able to replace the original Model3DGroup by your...
6 Jun 2013 by Stephen Hewison
The bit you're missing is the IXmlSerializable interface. Because your XML is not a standard XML produced by the .Net serialization libraries. You'll require a custom process.IXmlSerializable Interface[^]public class Recognition : IXmlSerializable{ public string radio; public...
8 Jul 2013 by chain1234
Use the AppDomain to load another .NET assembly version.
7 Feb 2014 by BillWoodruff
Example of using BinaryWriter, and BinaryReader to save a Dictionary>:// requiredusing System.IO;private Dictionary> testDict = new Dictionary>();private string appPath =...
17 Feb 2014 by Pete O'Hanlon
Marhalling tends to be the term used to describe the process of transforming data so that it can either be stored (i.e., marshalling data), or moved. So, when you hear about an event being marshalled, what this means (in effect) is transforming the event so that it can be moved over threads - in...
17 Feb 2014 by mehdijafary
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file, a memory buffer, or transmitted across a network connection to be used later in the same or another computer environment. And this sequence of bits can be of any...
23 May 2014 by Jaume González
Easy seralization by adding extension methods to generic class
30 Jan 2015 by Afzaal Ahmad Zeeshan
The problem is that the required assembly is not found in your project. In the first line of the Exception, it is stated clearly, that the assembly (you can say, the .dll library or the package) required to deserialize, is not found. Did you include that package inside your project? Include (or...
6 Oct 2015 by ZurdoDev
Looks like you got an answer, http://stackoverflow.com/questions/32973585/salar-bois-serialization-to-disk[^]
10 Mar 2016 by lukeer
Did you have a look into the XmlSerializer Class? XML Schema Definition Tool (Xsd.exe) should be able to create classes from your schema that are serialized into documents at runtime.
13 May 2016 by Dmitriy Gakh
I have no enough data about your solution and logic, but this code seems working without runtime errors (if it does not resolve your problem completely, it could be helpful to improve the situation and understand the code better):private void btnDelete_Click(object sender, EventArgs e) ...
1 May 2017 by FranzBe
1) Well, if you look into the inner exception you see that the namespace of the xml is not known 2) To get along, I would first build a valid object, then serialize it and see how the valid serialized structure looks like. A base class that does the serialization and deserialization might help...
24 Apr 2018 by Kornfeld Eliyahu Peter
I used this set of declarations and all works well: public enum LoanIdentifierBase { NotSet, AgencyCase, InvestorCommitment, InvestorContract, InvestorLoan, InvestorWorkoutCase, LenderCase, LenderLoan } public...
22 Jul 2019 by OriginalGriff
Quote: But I am having error at the same line, it says access denied, I don't know why Access denied is pretty obvious: the user that the code is executing under does not have the rights to the file or folder it it trying to open. You can't fix that; it's a feature of the OS, and the only way...
23 Jul 2019 by OriginalGriff
Look at what you are doing: string json = JsonConvert.SerializeObject(c1, Formatting.Indented); File.WriteAllText(path_combined, json); string json2 = JsonConvert.SerializeObject(c2, Formatting.Indented); File.WriteAllText(path_combined, json2); WriteAllText does what it says: creates a new...
11 Nov 2019 by OriginalGriff
First off, your classes don't entirely match the JSON: if you add the appropriate curly brackets to your data to make it "valid JSON" and run it through a class generator: json2csharp - generate c# classes from json[^] then you get a load of "__invalid_type__" classes generated which means that...
27 Mar 2020 by phil.o
You do not serialize the controls themselves, you just serialize the information needed to (re)build them.
3 Apr 2020 by OriginalGriff
Because the syntax you are using is trying to construct a List and assign properties of that list. What you need to do to supply new instances of the MatchActionsReason class and assign those properties: matchActionsReasons = new...
22 May 2020 by RickZeeland
Try this code generated by JSON Utils: Generate C#, VB.Net, SQL Table, Java and PHP from JSON[^] public class Content { public string Type { get; set; } public string Campaign { get; set; } public string...
2 Nov 2020 by Richard Deeming
Plenty of examples in the documentation: Examples of XML Serialization | Microsoft Docs[^] Dim xsSerialize As New XmlSerializer(GetType(List(Of Scanner))) Using fs As Stream = IO.File.OpenRead(path) Return...
8 Nov 2020 by Richard Deeming
Either remove the DefaultValue attribute, or override the default value when you serialize to XML: XmlAttributes.XmlDefaultValue Property (System.Xml.Serialization) | Microsoft Docs[^] public XmlSerializer CreateSerializer() { var...
17 Aug 2021 by Greg Utas
That's a very generic error that doesn't say why abort was called. But press Retry and use the debugger to find the problem. If you don't know how to use a debugger, Visual Studio has lots of documentation about it. Using a debugger is...
29 Dec 2021 by Chris Copeland
Take a look at this XML serialization documentation page[^]. As Richard mentioned in his comments, you can use an XmlArrayItem attribute to indicate a collection of values. Ie. public class Dimension { [XmlArrayItem("element")] public...
4 Aug 2023 by Richard MacCutchan
Quote: Kindly provide the site to download the same. The link for downloading is provided on the site that you linked to in your question. Quote: I tried using cmake to build visual studio 2013 solution but it is throwing errors,probably...
27 Aug 2019 by C Pottinger
Hello folks. I can really use some help here. What I am attempting to do is to create an XML serializer that can handle a class that has several derived subtypes. I already know the basics of doing this: I wrote this blog entry to help me remember how. But now, I am diving a little deeper and...
15 Jan 2012 by thomas_wingfield
Hello everybody!I'm beginner of Silverlight.I use Silverlight 4 for my project.I have custom class with BitmapImage property.Currently all my properties has tagged DataMember and BitmapImage tagged IgnoreDataMember. I must serialize this class, but after some hours I couldn't find nothing...
1 Feb 2012 by Shivangi Singh
I m consuming a third party web service developed on Java. The get menthod is taking request class type object and its return type is a response class type object.I m getting the above error when calling the get method.When below line is executed my requset is reaching at there end but I m...
1 Feb 2012 by Kreagan Naicker
Hi Shivangi.With the above information it is nearly impossible to determine what the issue could be.This is most likely the 3rd party web service having a bug.Also something that you could check is the input data you are supplying in the "request class type object". Is all the data...
12 Feb 2012 by John R. Shaw
The solution is to use [XmlText()] for correct results.Example:public class MYELEMENT1{ [XmlText()] public string value;}public class MYELEMENT2{ [XmlText(typeof(int))] public int value;}Result of Serializing...
18 Jul 2012 by Rahul K Singh
Hi,I want to serialize font type of propert in a class. Class is serializable but error comes because of font type of propert. How can I serialize this property?
13 Aug 2012 by Mehdi Gholam
Wiki is a good place to start : http://en.wikipedia.org/wiki/Data_transfer_object[^]
13 Aug 2012 by Kenneth Haugland
You should always check the Microsoft documentation, it usually gives you a good startingpoint:http://msdn.microsoft.com/en-us/library/ff649585.aspx[^]
15 Aug 2012 by Seatech
Very short question:Why does this class(TCtsPageAdmin) have to be marked [Serializable]?I'm just trying to serialize a List TCtsPage class is marked properly.If I mark TCtsPageAdmin properly with the [Serializable] attribute, then the error moves up the hierarchy -> the...
15 Aug 2012 by Mehdi Gholam
All object used in TCtsPage must have a [Serializable] attribute.Alternatively if you can use my serializers which don't require anything and are faster than the BinaryFormatter:fastJSON[^]fastBinaryJSON[^]
16 Sep 2012 by m.bleimuth
Hi,i have a short hopefully simple question. I am trying to save a settingsobject using XML Serializer. The object contains some base types like int, string, double,and a struct called unit. The struct is defined in one of my third party dependencies. When I serialize the whole object...
18 Sep 2012 by Coxianuk
I Found the solution and documented here.Serializing Complex Data Containing XDocument[^]
28 Sep 2012 by m.bleimuth
JsonSerializerSettings set = new JsonSerializerSettings();set.TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;set.TypeNameHandling = TypeNameHandling.All;set.Formatting = Newtonsoft.Json.Formatting.None;When using this settings for...
30 Sep 2012 by MAU787
hi to all.I am serializing my object / converting it to XML dataand passing to another page and again Deserializing it.i am using following function to serialize and Deserializing public static string Serialize(object objectToSerialize) { MemoryStream mem =...
5 Oct 2012 by Sergey Alexandrovich Kryukov
You don't need to avoid anything, ever. Your Member1 and Member2 are still different object and should be serialized, as soon as you have them in the contract. If they serve the same purpose by some weird reason, don't use the [DataMember] attribute for one of them.A side advice: also use...
4 Dec 2012 by Richard C Bishop
I am creating a service that accepts a stored procedure and user input from an ASP page and is supposed to return the data in XML format back to the page. I am having trouble trying to figure out how to accomplish this. Can anyone suggest a better way to go about this and/or explain the flaw in...
4 Dec 2012 by Teenustar
Try this With Genericspublic static string SerializeToXml(T value){ StringWriter writer = new StringWriter(CultureInfo.InvariantCulture); XmlSerializer serializer = new XmlSerializer(typeof(T)); serializer.Serialize(writer, value); return...
10 Dec 2012 by Mazen_wadi
Hello there,I am trying to build a simple chatting application using .net remotingWhen the string in the remoting object is changed the remoting object will rise an event which should be handled by the clients, so when i try to attach the Handler to -i am using vb.net- the event...
10 Dec 2012 by Pascal-78
Articles about .NET Remoting events can be found on codeprojectlike this one:.NET Remoting Events Explained
12 Dec 2012 by dexterama
I think I'm missing something in my C# Serialization understanding. I am serializing a C# class to XML to transfer across a web service. For simplicity's sake, I have a class with only three properties:public partial class MyInfo : SerializableObject{ private string ssnField; ...
12 Dec 2012 by dexterama
I found the answer! It was an missing descriptor:[XmlElement(IsNullable = true)]public string SSN
23 Dec 2012 by Member 9622894
Hi,I want to serialize a class and send it over tcp. Thats no problem, but I get an exception while deserializing the stream in the client application.Thats my code:[Serializable]internal class SendObj1{ public int cmd; public string msg;}public class SendObj{ ...
28 Dec 2012 by Jibesh
The exception says Root Element is not found. Since your are using XmlSerialization you need to set the RootNode. change the serializable class as below[Serializable][XmlRoot]public class SendObj1{ [XmlElement] public int cmd = 0; [XmlElement] public string msg =...
18 Jan 2013 by AnnieM
I am creating a web service to fetch the employee data. I am using EF 4.0 and have created a serializable employeewrapper class accessible in webservice.I need help in serializing the foreign key relationship classes to access the related data as well.How to make Designation and Client...
18 Jan 2013 by Manaswinee
Please have a look at below link.http://stackoverflow.com/questions/639303/how-to-serialize-collections-in-net[^]
30 Jan 2013 by EnzeroX
I have a tried list, array and all different typesI have a list of items which is serializing just finein c#public List TransactionLines = new List();in vb.netPublic WithEvents TransactionLines As New List(Of Item)xml output is ...
31 Jan 2013 by EnzeroX
By using the XMLArray attribute rather than XMLElement it will be serialized as required.
31 Jan 2013 by Stephen Hewison
Hi,I'm implementing a project where I have a complex state object which needs to be stored away and at a later date consumed by a number of different services.The nature of this state object is that it is going to evolve where additional properties are added to the object.My concern...
31 Jan 2013 by Stephen Hewison
In asking my question I found the right terminology to find the answer in google.From .Net 2.0 onwards the framework has supported "Version Tolerant Serialization".This provides a number of tools for managing serialisation and deserialisation of object of different versions.These...
14 Feb 2013 by Mehdi Gholam
Naming things is hard and some times you make a decision early on and the name sticks and can't be changed.
20 Feb 2013 by belea17
I have im my design a Tri State TreeView for which I create a xml file to serialize. I create my xsd schmea and then i have generated my class for that schema (workflow.xml -> workflow.xsd -> workflow.cs)I want to parse in xml values "1" or "0" if a box from Tri State is checked or notMy...
21 Feb 2013 by belea17
If I run my code as it is, it will write the last part, from below code, for mc object WorkflowModulCapturaPrelucrareCaptura mc = new WorkflowModulCapturaPrelucrareCaptura(); if...
22 Feb 2013 by Jegan Thiyagesan
Hi,[Serializable][XmlR...
19 Oct 2017 by ibrahim_ragab
using xsd.exe tool to create XML Schema (XSD) for the following file 12 08:00 09:00 10:00 11:00 12:00 13:00 14:00 ...
22 Mar 2013 by Member 8681301
I have one application that is using a BinaryFormater to serialize a class, I will call class A, that contains a single property with is a List of T containing another class, I will call class B. I am using a second application to deserialize this class. A Google search found the MSDN and other...
22 Mar 2013 by Steve44
From what I understand in your question you are actually serializing and de-serializing different classes that are looking the same, but CLR is treating them as different since they are declared in independent assemblies.A common way to solve this is creating a new assembly that contains all...
8 May 2013 by Sergey Alexandrovich Kryukov
Please see my comment to the question.The best method is perhaps the Data Contract:http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].Please see my past answers where I advocate this approach:How can I utilize XML File streamwriter and reader in my form...
8 May 2013 by Thomas Daniels
Quote:So, what are the ways of saving the objects to files in Windows 8 apps(C#).Have a look at this Tip:Windows 8 App - Data storage in files using Windows.Storage namespace[^]
29 May 2013 by sambit85
I am trying to write a data table to xml and again reading it back to my application.This is the structure of my DataTable ---> Note : It is having a column of DataTable type. DataTable _clsdatatable = new DataTable(); _clsdatatable.Columns.Add("WIZARDID",...
29 May 2013 by JitendraSahu
// By using this method we can convert datatable to xmlpublic string ConvertDatatableToXML(DataTable dt){MemoryStream str = new MemoryStream();dt.WriteXml(str, true);str.Seek(0, SeekOrigin.Begin);StreamReader sr = new StreamReader(str);string xmlstr;xmlstr =...
29 May 2013 by sambit85
I have solved this --- The trick was not to use WriteXMl() method for datatabel -> xml. Instead i used loadxml() and then when I tried to read that xml by ReadXML() method it worked fine.Also the same can be possible with binary serialization.--- Any way thanks for your comments.
5 Jun 2013 by le.Festin
Scenario:I have a class which contains the following:[Serializable]public class Model{ public string Name { get; set; } public List Cameras { get; set; } public int DefaultCamera { get; set; } public bool IsDefaultLightON { get; set; } public...
6 Jun 2013 by Jeankininho
Hi, I tried many times with this objectpublic class Recognition { public string...
13 Jul 2013 by Sugu Thomas
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.Security;using System.IO;using System.Data;using System.Data.SqlClient;using System.Web.Configuration;using...
13 Jul 2013 by Zafar A khan
Create both Category and subcategory in one button click (i-e) create both in single click
8 Aug 2013 by E.F. Nijboer
Binary serialization is mostly suitable for use by an application internally and not really useful for data interchange. The obvious reason is that the format can be very specific between different framework versions. A better alternative would be to use xml or json formatters because these...
27 Aug 2013 by satyapratap
I am Balu from Hyderabad. I have writing WCF Restful services for our Andriod / Iphone developers. They can use JSON format so that we are choosing REST. Actually we can do Mobile Application only one APP that can runs differnt projects. All the projects are dynamically comes from WEBSERVICE to...
15 Sep 2013 by leonidasvijay
Hello guys,I have question on serialization.I have made a form object and added some controls in it dynamically.So, I want to save that form along with the controls in it.That's why I decided to serialize the form object.But when I call serialize the form object, an exception...
16 Sep 2013 by Mehdi Gholam
UI objects like Forms etc. are not meant to be serialized in this way, you are better off creating a "state" object within your form which will keep useful information and serialize that object instead.
25 Sep 2013 by ShacharK
Hey,Lets say I have a class which contains an internal sensitive structure whose content I don't want to reveal to my user when he receives an object I've serialized, but it is essential that he would have receive this data (a token...)In other words, I'm interested in replacing this...