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

Strange problem when deserializing

I'm sorry this message is so long.
I have had to make some changes to an application written by a previous
developer who used unmanaged serialization to store complex objects to file.
The application is a RAD form designer to design screens for an embedded
system and he only allowed for a single type of target system.
My company now needs a designer for a 2nd type of system but because of the
unmanaged serialization, any changes to the application to allow for more
than a single set of form controls causes old project files to fail to load.
It's imperative that old projects can be opened.

The only solution I can come up with, because (due to time) it's impossible
to debug or write a file converter, (and I only want to maintain a single
set of source) is to compile an application for each target using
conditional defines.

There is only one control that differs from those found in the original
system.
This control is a simple label that can represent/display 1 of a possible 50
variables that are updated in real time. The list of variables is held as an
enumeration within the class and, in the designer, is selected from an list
in the property editor eg "ERT" or "NUM". To go with the enumeration are
matching arrays of string descriptions and display formats eg "###.#"

The simplest solution I could think of was creating the enumeration (plus
lists), for the 2nd control, and using conditional defines to select which
enumeration was used during compilation. I then compile the application
twice, once for target 1 and the other for target 2.
When testing.
Serializing target app 1. Old files read successfully. New files written
successfully. New files read successfully.
Serializing target app 2. (no old files to test). New files written
successfully. New files read unsuccessfully and fail with error message

"A first chance exception of type 'System.InvalidCastException' occurred in
skinlibrary.dll
Additional information: Specified cast is not valid."

Running target app 2. If I try to open one of the Old files (created by
target 1 app prior to changes), this opens with no error. It also opens
target 1 apps new files (post change) successfully.

As I say, all Ive done is added an alternative enumeration and 2 string
arrays.

Im not sure if Ive done something wrong, or if the application is getting
confused between dlls or there's something else.
For the original application, I use Debug/Release configs. For the 2nd
application I created DebugStr/ReleaseStr configs which contain the STR
conditional define. These have their own subdirectories off the \bin
directory.

Can anyone help please to find the source of the problem. Thanks


Jun 21 '06 #1
2 1600
Perhaps I am looking at this too simplisticly, but when saving your
project types for the new type of system, why not just have a flag in the
file that indicates what kind of serialization you are using? If no flag
exists, it is assumed it is the old version.

You can then look for this flag, and then branch your processing off
accordingly.

The conditional complilation solution seems VERY excessive to me.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Chukkalove" <so*****@microsoft.com> wrote in message
news:un**************@TK2MSFTNGP04.phx.gbl...
I'm sorry this message is so long.
I have had to make some changes to an application written by a previous
developer who used unmanaged serialization to store complex objects to
file.
The application is a RAD form designer to design screens for an embedded
system and he only allowed for a single type of target system.
My company now needs a designer for a 2nd type of system but because of
the unmanaged serialization, any changes to the application to allow for
more than a single set of form controls causes old project files to fail
to load. It's imperative that old projects can be opened.

The only solution I can come up with, because (due to time) it's
impossible to debug or write a file converter, (and I only want to
maintain a single set of source) is to compile an application for each
target using conditional defines.

There is only one control that differs from those found in the original
system.
This control is a simple label that can represent/display 1 of a possible
50 variables that are updated in real time. The list of variables is held
as an enumeration within the class and, in the designer, is selected from
an list in the property editor eg "ERT" or "NUM". To go with the
enumeration are matching arrays of string descriptions and display formats
eg "###.#"

The simplest solution I could think of was creating the enumeration (plus
lists), for the 2nd control, and using conditional defines to select which
enumeration was used during compilation. I then compile the application
twice, once for target 1 and the other for target 2.
When testing.
Serializing target app 1. Old files read successfully. New files written
successfully. New files read successfully.
Serializing target app 2. (no old files to test). New files written
successfully. New files read unsuccessfully and fail with error message

"A first chance exception of type 'System.InvalidCastException' occurred
in skinlibrary.dll
Additional information: Specified cast is not valid."

Running target app 2. If I try to open one of the Old files (created by
target 1 app prior to changes), this opens with no error. It also opens
target 1 apps new files (post change) successfully.

As I say, all Ive done is added an alternative enumeration and 2 string
arrays.

Im not sure if Ive done something wrong, or if the application is getting
confused between dlls or there's something else.
For the original application, I use Debug/Release configs. For the 2nd
application I created DebugStr/ReleaseStr configs which contain the STR
conditional define. These have their own subdirectories off the \bin
directory.

Can anyone help please to find the source of the problem. Thanks

Jun 21 '06 #2
I fixed it. I'd been having so many problems with serializing I didnt notice
that this was a casting problem. The object deserialized wasnt the sort
expected. So i fixed that problem (previous developer had hardcoded some
file extensions) and the problem went away
thanks anyway
:)
Jun 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mikael.lindqvist | last post by:
I have a program that calls a web service using the PEAR SOAP extension. The problem is that on one machine it works and on another it doesn't. The actual part of the conversation that specifies...
1
by: Thomas | last post by:
Hi, I implemented a composite pattern which should be serializable to xml. After spending some time in the newsgroups, i finally managed serializing, even with utf-8 instead of utf-16, which...
0
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:...
3
by: Don McNamara | last post by:
Hi, I've hit quite a strange problem with XmlSerializer on my W2K3 server. When I serialize/deserialize using an exe on my local computer (XP), everything works fine. When I put the code out on...
0
by: JMD | last post by:
I have a set of schemas for two different XML files that share common structures through the use of "import". Eventually, the main XSD file (which just gathers pieces from the common stuff to...
1
by: Bob Rock | last post by:
Hello, always having to validate an XML stream against a XSD may add up an important overhead. My XMLs are usually the result of serializing a class instance and often in my applications what I...
0
by: theonlydavewilliams | last post by:
Hi there I'm hoping there's an easy answer to a (hopefully) not too long-winded issue... I'm building a C# web client using a proxy wsdl.exe'd from a wsdl file and six schemas, each in a different...
7
by: Looch | last post by:
All, I'm using a WinForm app that calls methods on a remotable object. The app server hosting the object is in New York. Using the same exact application, a Sql Server 2005 datetime column's...
0
by: ullner | last post by:
I have an XML fil that looks like this: <Environment> <AreaOfInterest> <Name>ScenarioMap</Name> <UpperRight> <GDC> <Latitude>-179</Latitude> ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
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
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...
0
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...
0
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...
0
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,...

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.