Click here to Skip to main content
15,892,643 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 Updated

Serialization 

9 Jan 2017 by #realJSOP
3 Ways to Convert DataTable to JSON String in ASP.NET C#[^]
8 Nov 2020 by .Net Perfect Dev
Hello, I try to serialize a n object to xml file.this object containt a property length [System.Xml.Serialization.XmlAttributeAttribute()] [System.ComponentModel.DefaultValueAttribute(1D)] public double Length { ...
4 May 2014 by _Asif_
Below article explains similar problem and provide a solution. Please checkDataContract XML serialization and XML attributes[^]
8 May 2013 by Abhinav Varma
(Windows 8 Apps, C#)Hi,I have a number of Images(.jpg) and Audio-files(.mp3) in each object. I would like to store these objects in separate files and retrieve the content later. I searched for Object Serialization, but could not find a right example for Windows 8 apps. So, what are the...
18 May 2013 by Abhinav Varma
I am getting an Exception: An exception of type 'System.Runtime.Serialization.InvalidDataContractException' occurred in System.Runtime.Serialization.dll but was not handled in user codeAdditional information: Type 'Windows.UI.Xaml.Media.ImageSource' cannot be serialized. Consider marking...
17 Aug 2021 by Adam Aug2021
I currently have a class that uses a pointer vector to another class. Everything has worked fine until I began implementing boost serialization. On the first run with the program, everything works fine and appears to save the data into the .xml...
17 Aug 2021 by Adam Aug2021
Thanks for the help all. Turns out all I had to do was switch from xml to text (ie. xml_oarchive to text_oarchive). Not sure what happened there but I don't have the time to keep fiddling around with it as the beginning of the semester is closing in.
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...
1 Dec 2019 by Aishwarya Hegde
This should be possible however I have searched extensively and have found no answers to this, using WCF ISerializable interface concept. Hopefully the experts can help. Any documentation I have read only refers to info.AddValue(...) concept similar to the ones in...
2 Feb 2023 by Akshay malvankar
I stored images in database in base_64 format. Fetching that data from a controller to html using Ajax. While fetching record from in controller, I get the following error in custom filter exception: Error during serialization or deserialization...
13 Apr 2018 by Alaa Ben Fatma
In this article, we will walk through the basic concepts of de/serialization and how to create a very basic de/serializer.
17 Feb 2015 by Alberto M.
This article describes the file format NBT and shows how can be implemented in a real application to store data.
20 Mar 2018 by Alex Pumpet
A simple program for comparing table data from two sources - SQL databases, Excel, CSV or XML-files
14 Nov 2013 by Ambivert
Hi All,I have waste lots of time in this, still scratching my head. I have this WCF service in my project ::namespace XYZ.ABC.Services.ServiceObjects{ [DataContract] public class SpecimenType { [DataMember] public DateTimeOffset CreateDate { get; set;...
3 Apr 2013 by Amit Bezalel
How to assert an object state using only 2 code lines
30 Oct 2014 by amitgpatil@gmail.com
Hi,I am serializing following class object.This class is linked list.------------- MyClass.h-----------class MyClass : public CObject{protected: MyClass *m_pNext; int var1; enum1 var2; enum2 var3; enum3 var4; double[3] m_Normal; public://...
15 Jul 2015 by Andy Lanng
Hi ^_^Just when I think my Workflow Engine is in order, this happens >_So, I have an instance of an IMessage that I need to clone. here is that process:public IMessage Requeue(){ //New instance of this object. Clone() is below var message = Clone(); ...
25 May 2012 by Anetics
Hi All,Im having a problem serializing an xml documentMy document is structured like this: Logon.aspx https://........ 336 ...
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...
8 Aug 2013 by Antal Dominik
I'm trying to read a binary serialized object, that I don't have the object definition too. I took a peak into the file and saw property names, so I manually recreated the object (let's call it SomeDataFormat).I ended up with this : public class SomeDataFormat // 16 field { public...
2 Dec 2019 by Ashutosh Gpt
serialize in this way and it works var xmlSerializer = new XmlSerializer(typeof(myObject)); using (var xmlStream = new MemoryStream()) { xmlSerializer.Serialize(xmlStream, root); xmlStream.Position = 0; var xmlDoc = new...
11 Oct 2013 by ASP.NET Community
The process of serialization converts an object into a form so that it can be transported across the network or can be placed in a storage location.
13 Jul 2015 by avadin20048
[XmlRoot("MachineData", Namespace = "")] public class MachineMessage : BaseEntity { #region == Fields = private List _content; #endregion #region == Properties == public T Content { get { return _content;...
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...
20 Jun 2014 by Bert Goens - HW
Hello codeproject,I have a project and I don't know if I should make my enum serializable or if it won't affect the use of my project. This is how it works:public enum ColorOfFood { values }[Serializable]public class Food{ private string name; private ColorOfFood...
24 Jun 2014 by bginsburg
I'm trying to cast DataTableReader to NpgSqlDataReader (its an abstract class) with no success. tried inheriting from it but than i cant because it has internal function that could not be override. The final thing im trying to do is move an object of NpgSqlDataReader from one process to...
9 Jun 2014 by Bilel Msekni
How to properly replace base classes with sub classes in WCF contracts ?
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 =...
5 Jul 2018 by Bimal pedini
Just try to merge all the json files first and keep it in a single Json file and do Serialize and Deserialize that. bject o1 = JObject.Parse(@"{ 'FirstName': 'John', 'LastName': 'Smith', 'Enabled': false, 'Roles': [ 'User' ] }"); JObject o2 = JObject.Parse(@"{ 'Enabled': true, ...
18 Jul 2014 by Bjørn
A custom Json state machine parser, viewer and serializer for Json data
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.
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
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...
25 Apr 2018 by C. David Johnson
I'm working with a 3rd party file so I did not design the structure, and I'm stuck with it. For some reason all my enums are selecting the first value in the list instead of the correct one First here is my deserialization code using (var stream = new FileStream(filetoimport,...
25 Apr 2018 by C. David Johnson
This is a STUPID solution but it works, public LoanIdentifierBase Value { set; get; } Was changed to [XmlText] public string RealValue { set; get; } public LoanIdentifierBase Value => (LoanIdentifierBase) Enum.Parse(typeof(LoanIdentifierBase), RealValue); With this the...
8 Jul 2013 by chain1234
Use the AppDomain to load another .NET assembly version.
19 Jun 2018 by Chirag Sudra
Hi, I am trying to serialize List to json but data which is return after serialzing misses some data from between and replaced with 3 dots (...). For converting object to Json I am using Newtonsoft library. After some R&D, I found out that it is the issue of json length. So can you...
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...
6 May 2019 by Christian Graus
If you make a request and get that back, then that's what you were sent. If you know there's a prefix and you don't have access to the server code, use SubString to remove it
10 May 2013 by CognitiveFeedback
General solution to Serializing and Deserializing CSV files.
17 Sep 2012 by Coxianuk
Hi,I have a complex object graph that contains properties that are of an interface type and the implementation of one of those interfaces uses an XDocument backed property. I need to serialize this object graph to XML for rehydrated unit test data. XML is preferred so I can edit the data in...
18 Sep 2012 by Coxianuk
I Found the solution and documented here.Serializing Complex Data Containing XDocument[^]
20 Nov 2014 by CPallini
You may either write your own code for serializing a vector (which in turn serializes all the items of the vector) or use, for instance, boost::serialization[^].
15 Apr 2015 by CPallini
vinod b v wrote:I am supposed to get 25ms low and 25ms high square wave upon sending byte 0xF0 at 200 baud, and next my 5 databytes should be sent at 10400, but i am not able to see the exact waveform in my oscilloscope. is there something wrong in the code??What do you see on the scope?...
22 Jan 2018 by CPallini
As far as I know there is no built-in serialization feature in C++11. I guess some new language (and library) features may help you in writing serialization code, however I'm not aware of any of them specifically introduced to make serialization easier.
13 Jul 2015 by ct_12
I can not deserialize the current JSON format. When I try to use some tools to generate the deserialize object it generates something like that ;public class RootObject{ public List> ImageList { get; set; }}JSON Format ;{"ImageList": [ [ { ...
17 Jul 2019 by Danny96
I am trying to save the updated values(save and reload) to a text file When user closes, re-opens, we should see the where it left off. 1)In this code, I have a button that changes the flag values to true, BUT, the main class does not see the changed flag values. Still, the old values are...
23 Jul 2019 by Danny96
EDIT: I fix the previous errors, I understand my problem with the code is related to writing a blank file; when I click my button to set values to write a file; It says my "c1" object is empty. System.NullReferenceException: 'Object reference not set to an instance of an object.' at this...
23 Jul 2019 by Danny96
Hello, I am (de)serializing the json strings to txt file. In my code object "c2" successfully does that where object "c1" fails to serialize and deserialize. Since object c1 fails, its boolean flags do not change. I searched for solutions, I saw some people merge the strings, and some use...
17 Oct 2012 by dartfrog
Hi all, currently i have a json string like the following:{"1058 NAMER":"1058 solid|10|C1|MOOD","0 NAMER":"0 solid|10|C7|MOOD","1891 NAMER":"1891 solid|10|C2|MOOD","1403 NAMER":"1403 solid|10|C3|MOOD","1487 NAMER":"1487 solid|10|C4|MOOD"}How can i deserialize it and put it...
12 Jun 2016 by DataBytzAI
Useful code for your toolbelt - generic save/load an object in XML
12 Sep 2018 by Dave Kreskowiak
Forms and Controls are not serializable. You have to create your own serialization scheme from scratch. This means creating a data structure to hold all of the information you want to keep track of, such as the type names of the controls you want to save, and all the data required to recreate...
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.
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.
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
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...
14 Dec 2015 by DimitriStPi
Hello there,I'm currently working on a project of WPF application which allows me to configure a XML file. This application has to load a XML file and permit the user to dynamically change the attributes values.I try to use the XmlSerializer object, but its native behavior doesn't match...
14 Dec 2015 by DimitriStPi
So... There is a solution ! What we have to do is rather simple.. If our class Attribute looks like the following one : { public class Attribute { public Attribute(string name, int value) { this.Name = name; this.Value = value; ...
28 Apr 2015 by dinesh_redhawk
I have to parse the data from a very big xml file with lot of repeatetive elements and child nodes. I could have used the GetElementsbyTagName but that will be a very lengthy and complex solution w.r.t this xml file.I think the best method would be xml serialization and deserialization...
22 Dec 2017 by Dirk Bahle
Tips & Tricks on loading and saving WPF Tree View based content.
18 Jan 2018 by Dirk Bahle
Tips & Tricks on de/serializing Tree View based content with XML
21 Apr 2015 by DlogDash
It appears that DataContractJsonSerializer uses different precision to NetDataContractSerializer for DateTime. Testing of serialise-deserialise failed for a DateTimeOffset property if used strict equality or testing to the nearest Tick.The following code snippet fixed the issue (_entity1 was...
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) ...
6 Feb 2014 by Duncan Edwards Jones
If I have a class with read-only properties that I only want to be created at constructor time e.g.:-Imports System.Runtime.Serialization''' ''' An event to indicate that an FX rate was priced between two currencies''' Public Class...
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...
3 Jul 2015 by ebirazavi
I have written a program that enable users to generate some objects in WPF Canvas and run animations to them with set time. I used Xaml Serialization to save this objects stream and Deserialization to load events. I want to create video from steram and events. Is there any way to record events...
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.
7 Dec 2015 by F-ES Sitecore
There is a difference between a child property and an array. A child property is like{"parentID":123, "child":{"childID":456}}An array of three children is{"parentID":123, "children":[{"childID":1}, {"childID":2}, {"childID":3}]}An array of one child is{"parentID":123,...
22 Jun 2015 by Fiyaz Hasan
Building an outlook calendar app for windows phone using Live SDK
28 Sep 2012 by fjdiewornncalwe
How is this for an answer: Clicky[^]
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...
21 Dec 2013 by fre_ber
Hi, I have been trying to load and save the layout of an Avalon docking manager with mixed success.Just doing the basic thing works as expected: private void OnSaveLayout() { XmlLayoutSerializer layoutSerializer = new...
12 Aug 2015 by Gaurav Aroraa
How to Serialize/Deserialize objects programatically?
18 Jun 2019 by Gerry Schmitz
You serialize an "object" i.e. Class. Doesn't matter if it's a "parent" or a "child". If the "object" is serializable as well as its children, then that "object graph" can be serialized. Whether what you are doing is actually beneficial is another matter.
2 Nov 2020 by Gerry Schmitz
You can't serialize a collection directly; it needs a "parent" / root. e.g. (in c#) [DataContract()] public class FengShuiStorage : IExtensibleDataObject { public ExtensionDataObject ExtensionData { get; set; } ...
7 Dec 2015 by Gopi krishna.ch
Here I have a scenario that Create xml file dynamically and it should be serialisable and my xml is like...
19 Feb 2017 by Graeme_Grant
This may help you: Convert XML to C# Classes[^]
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...
12 Mar 2017 by Gregory Morse
Deserialization and serialization classes for JSON objects in native C++ with COM and ATL
4 Dec 2016 by hairy_hats
Hi all,I have a problem deserializing a file created with a VS2010 C++ program using a more-developed VS2015 version of the same program.Some of the classes have been moved into DLLs, and I have changed the DECLARE_SERIAL and IMPLEMENT_SERIAL macros appropriately. Almost all old files...
4 Dec 2016 by hairy_hats
An ancient patch wasn't allowing the Class map in the CArchive deserialization code to be built up correctly once the classes were moved to the DLL. All working now.
13 Aug 2012 by Hitul Mistry
I'm beginner to c# i wan't to learn all the stuff of DTO, also serialization so snuggest some good articles that teach it from begining.
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...
1 May 2020 by honey the codewitch
Creating an application that can run once, but then accept command line args from subsequent runs
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 ...
18 Jun 2015 by Icoon
Did you already checked this article: https://msdn.microsoft.com/en-us/library/58a18dwa%28v=vs.110%29.aspx[^]
26 Jan 2016 by infal
How to write / read multidimensional arrays to/from BinaryWriter/BinaryReader or other stream using UnmanagedMemoryStream
24 Jan 2012 by Jack Z. Stone
How to use Xaml.XamlServices to serialize or deserialize a DependencyObject.
13 May 2015 by Jalal Ali
A guide on sockets, and how to send objects across them
12 May 2015 by James Gordon
hey guys! So I have been working on a project and it's 99% done,all I need to do is add in a Reader for XML.I have a Serialized Data Class that gets and sets most of my objects in my program. All variables are converted to data.FirstNames etc like so... private void...
23 May 2014 by Jaume González
Easy seralization by adding extension methods to generic class
6 Jun 2013 by Jeankininho
Hi, I tried many times with this objectpublic class Recognition { public string...