473,398 Members | 2,188 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,398 software developers and data experts.

Strong name binary serialization and versioning problem

Hi, all
Two classes Foo1 and Foo2
Foo1 uses Foo2 as reference
Both are strong name signed with the same key pair
I'm performing Binary Serialization of object inside Foo2 from Foo1
as following:
------------------------------
IFormatter f = new BinaryFormatter();
Stream s = new FileStream(fileName,FileMode.Create,FileAccess.Wri te,
FileShare.None);
f.Serialize(s,graph);
s.Close();
----------------------------
and then Deserialize:
----------------------------
IFormatter f = new BinaryFormatter();
Stream s = new FileStream(fileName, FileMode.Open, FileAccess.Read,
FileShare.Read);
graph = f.Deserialize(s);
s.Close();
----------------------------
everythink working just fine, BUT
Making any change in Foo1 or Foo2 (recompilation) [WITHOUT MAKING ANY
CHANGES IN THE OBJECT FOR DE/SERIALIZATION] cause the following exception
throw and make the saved object undeserializable thus I can not read the
object from saved file anymore

System.Runtime.Serialization.SerializationExceptio n: Cannot find the
assembly Foo2, Version=1.0.1739.20447, Culture=neutral,
PublicKeyToken=8f3506f185b212ea.

Except it everythink working fine that means that Foo1 can find and use Foo2

Please advice
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
Nov 16 '05 #1
5 2571
Hi Tamir,
everythink working just fine, BUT
Making any change in Foo1 or Foo2 (recompilation) [WITHOUT MAKING ANY
CHANGES IN THE OBJECT FOR DE/SERIALIZATION] cause the following exception
throw and make the saved object undeserializable thus I can not read the
object from saved file anymore

System.Runtime.Serialization.SerializationExceptio n: Cannot find the
assembly Foo2, Version=1.0.1739.20447, Culture=neutral,
PublicKeyToken=8f3506f185b212ea.


Strongnames drives the CLR to use a more strict type binding.
The version number becames part of the assembly name.
Because your version number is automatically computed,
you get after every recompile a new incompatible assembly.

You should manually maintain the version number of the assembly.

bye
Rob
Nov 16 '05 #2
are there ways to take care on it I need versioning control in this app.

--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "

"Robert Jordan" <ro*****@gmx.net> wrote in message
news:cj*************@news.t-online.com...
Hi Tamir,
everythink working just fine, BUT
Making any change in Foo1 or Foo2 (recompilation) [WITHOUT MAKING ANY
CHANGES IN THE OBJECT FOR DE/SERIALIZATION] cause the following exception
throw and make the saved object undeserializable thus I can not read the
object from saved file anymore

System.Runtime.Serialization.SerializationExceptio n: Cannot find the
assembly Foo2, Version=1.0.1739.20447, Culture=neutral,
PublicKeyToken=8f3506f185b212ea.


Strongnames drives the CLR to use a more strict type binding.
The version number becames part of the assembly name.
Because your version number is automatically computed,
you get after every recompile a new incompatible assembly.

You should manually maintain the version number of the assembly.

bye
Rob

Nov 16 '05 #3
Hi Tamir,
are there ways to take care on it I need versioning control in this app.


After you've persisted the data, you have to stick with the
assembly version. BTW, the last version number (the "x" from "1.0.0.x")
doesn't count.

If you cannot deal with that limitation, you have to use
binding redirects in your App.config. See "bindingRedirect element"
in the docs.

bye
Rob
Nov 16 '05 #4
One of my students once claimed that he solved this particular problem by
using the filter level property as so:
bin.FilterLevel = TypeFilterLevel.Low

I haven't tested this myself but maybe it helps.

--
Patrik Löwendahl [C# MVP]
www.cshrp.net - "Elegant code by witty programmers"

"Robert Jordan" <ro*****@gmx.net> wrote in message
news:cj*************@news.t-online.com...
Hi Tamir,
are there ways to take care on it I need versioning control in this app.


After you've persisted the data, you have to stick with the
assembly version. BTW, the last version number (the "x" from "1.0.0.x")
doesn't count.

If you cannot deal with that limitation, you have to use
binding redirects in your App.config. See "bindingRedirect element"
in the docs.

bye
Rob

Nov 16 '05 #5
Hi Patrik,
One of my students once claimed that he solved this particular problem by
using the filter level property as so:
bin.FilterLevel = TypeFilterLevel.Low

I haven't tested this myself but maybe it helps.


One of my collegues proved that it wouldn't help ;-)
But he tried to *deserialize* already serialized
data. Probably it would help if the objects were
already serialized with TypeFilterLevel.Low.

bye
Rob
Nov 16 '05 #6

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

Similar topics

10
by: Tony Jones | last post by:
Can anyone think of a reason why a 3rd party vendor writing .NET components would NOT strong name their assemblies? What harm does adding a strong-name to assembly present - I would think none...
2
by: Dave Veeneman | last post by:
I'm working on a project where I have to persist data to a file, rather than to a database. Basically, I need to save the state of several classes, each of which will have a couple of dozen...
20
by: Razzie | last post by:
Hey all, I'm really going through a small hell right now - I've completely lost it :) I made a project, using two interop libraries from exchange (created them as in this msdn article:...
1
by: Tamir Khason | last post by:
I have a base class MyBaseFoo with some properties, methods etc. I have some derived classes, implements small part of MyBaseFoo and a lot of their own. In order to ensure proper deserialization...
1
by: Jimski | last post by:
Hi all, I am creating an assembly that will access a database to return record details. I need to deploy it to a 3rd Party and they will then be able to use the assembly in their code to...
6
by: Manuel Lopez | last post by:
Hello, I have a Web Project (UserControls.dll) with some user controls that is shared by many asp.net web applicattions. What we do is copy UserControls.dll to all the applications bin...
15
by: Jacques | last post by:
Hi I am an dotNet newby, so pardon my ignorance. I am looking for a method of saving/copying a managed class to a stream/file WITHOUT saving the object's state, eg. if I have a ref class with...
1
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
1
by: sandeepbhutani304 | last post by:
have 2 projects communicating each other with .NET remoting. But when I am trying to call these functions I am getting the error: The input stream is not a valid binary format. The starting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...

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.