I use serialization to write class data to a file. During my development of
this class I need to add properties or fields on occation. After adding a
property, when deserializing the data saved to disk I get an exception error
indicating that the class data members no longer match.
To avoid the exception errors, how can I retrieve data from the disk and
populate the existing fields found within the file and set defaults for the
new properties that I've created?
--
Steve 6 1579
Refer the following article, http://www.microsoft.com/india/msdn/articles/228.aspx
--
Regards,
Amal [MCP, MCS] http://geocities.com/techsharing
"Steve Teeples" wrote: I use serialization to write class data to a file. During my development of this class I need to add properties or fields on occation. After adding a property, when deserializing the data saved to disk I get an exception error indicating that the class data members no longer match.
To avoid the exception errors, how can I retrieve data from the disk and populate the existing fields found within the file and set defaults for the new properties that I've created?
-- Steve
I may have missed something while reading the article but it doesn't seem to
answer my question. What happens if I add an new field to my class after
data has been serialized to a file. When reading the old serialized data
back into my "new" class I get an exception error because the fields no
longer match. Currently I'm using BinaryFormatter , not xml.
--
Steve
"AMALORPAVANATH AN YAGULASAMY(AMAL )MCP,MCS" wrote: Refer the following article, http://www.microsoft.com/india/msdn/articles/228.aspx -- Regards, Amal [MCP, MCS] http://geocities.com/techsharing
"Steve Teeples" wrote:
I use serialization to write class data to a file. During my development of this class I need to add properties or fields on occation. After adding a property, when deserializing the data saved to disk I get an exception error indicating that the class data members no longer match.
To avoid the exception errors, how can I retrieve data from the disk and populate the existing fields found within the file and set defaults for the new properties that I've created?
-- Steve
Did you try out the NonSerializedAt tribute?
Regards,
Arun Prakash. B
I have and am using it on serveral fields that do not require serialization.
However, the addition of some fields will require serialization and therefore
must be serialized. Older versions will not understand the new field when
deserializing. Is there a way to ignore the fact that a new field exists
when deserializing?
--
Steve
"ar**********@g mail.com" wrote: Did you try out the NonSerializedAt tribute?
Regards, Arun Prakash. B
Ok. Now i see the actual problem. I dont know of any in-built mechanism
to do this. AFAIK, the idea Fred has suggested in the other thread
seems to be the best.
-----
Arun Prakash. B
Thanks for the time and suggestions!
--
Steve
"ar**********@g mail.com" wrote: Ok. Now i see the actual problem. I dont know of any in-built mechanism to do this. AFAIK, the idea Fred has suggested in the other thread seems to be the best.
----- Arun Prakash. B
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kenneth Baltrinic |
last post by:
I am getting the following error when deserializing an object that has a couple of dozen dependant objects in its object graph. Anyone who can suggest where I might begin to look to resolve problem I would greatly in debted to. Serializing the object works fine. When I try to deserialize it, I get the following error:
A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional...
|
by: Mark McConnell |
last post by:
Regarding deserializing XML into a custom object...
I've been able to deserialize an XML doc into my custom object and
everything works great. The problem I am encountering is when one of the
XML elements contains a NULL and it maps to a variable of type Integer in my
custom object, the deserializer doesn't like this.
For example, my custom object is declared like:
Public Class Member
|
by: Jon Fairchild |
last post by:
I am getting the following error when deserializing an XML with
attribute overrides:
"There is an error in XML document (2, 2) … <RulesConfig xmlns=''> was
not expected"
My XML looks like this:
<RulesConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="D:\Dev\Source\Miner.Data.Configuration\RulesConfig.xsd">
<RulePackage Key="SwitchingSteps" Caption="Switching Steps">
|
by: Wayne Wengert |
last post by:
Using VB.NET I want to read in an XML file that has an array of objects and
then step through the resulting array in code. I build a class to define the
structure and I am running code to read in the data but I can't figure out
where the data is in the resulting array. Most of the relevant code is
below. When I run the code to desrialize I get no errors but if I try to
look at some of the data via the command window I get errors such as...
|
by: Earl Teigrob |
last post by:
I am saving and restoring value types such as Int32, DateTime and Boolean in
strings. I was wondering if there is a mechanism build into .NET for
serializing and deserializing these to string format. I can, of course,
serialize a class to a file, either binary or XML, but this is not what I am
looking for. Currently I am using ToString() or Convert.xxx to do this, but
thought that if there was a true serializer, deserializer, that would be...
| |
by: Kevin R |
last post by:
Hi All,
I have a binary file, the first few k of which contains some
information which I need to stick in to an array of types,let's call
them Wongas.
Each Wonga is made up of two ulongs and a 24 byte character array.
I need to read in an array of Wongas from the binary file and I need
to specify how many to read in, as the file is only Wongas for the
first few k .What's more, the wongas don't start at the beginning of
|
by: Phillip Galey |
last post by:
I have an object called Place which contains only string properties and has
the <Serializable()> flag before the class name declaration. I also have a
collection object called Places, which is implemented using Inherits
System.Collections.Specialized.NameObjectCollectionBase and also has the
<Serializable()> flag before the class name declaration.
In the calling code, I'm successfully serializing the object to an XML file
using a...
|
by: Andrew E Chapman |
last post by:
What happens to an object which is not nothing has another object
deserialized into it? I assume that the data in it is completely destroyed by
the new object.
I am interested because I have some strange persisting data elements
cropping up whose origins I am attempting to identify. I was wondering if
deserializing in the manner described above might be responsible if the
original object is not actually destroyed.
|
by: Sivajee Akula |
last post by:
Hello All,
I am trying to consume a .NET Service from Adobe LiveCycle Workflow. The service deals with complex objects. I am getting the following exception at the time of invocation of the service, and due to which my workflow gets stalled.
When I searched the net, I found many posts reporting this error, but none with a solution. There is no code involved in the invocation, everything is handled by Adobe tool itself. I just specify the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
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();...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |