PC Review


Reply
Thread Tools Rate Thread

BinaryFormatter.Deserialize after signing of assembly fails

 
 
Henrik Skak Pedersen
Guest
Posts: n/a
 
      27th Jan 2005
Hello,

I have a class which is beeing serialized/deserialized using the
BinaryFormatter class. That has been working with no problems until I signed
all my assemblies. Now I get a SerializationException when I try to
Deserialize the class which has been serialized before the signing. So what
is best practice in my situation?

Do I have to convert all my saved classes or do I write a
SerializationBinder to handle it runtime?

If I delete all my data and run fra scratch it works fine until I compile my
assembly. Then the assembly gets a new versioand it fails on the version.
Why do I get this error now, i did'nt get it before I signed the assembly?

Best regards

Henrik Skak Pedersen


 
Reply With Quote
 
 
 
 
David Levine
Guest
Posts: n/a
 
      27th Jan 2005
I haven't tried to use a SerializationBinder to convert a stream from a
unsigned to a signed assembly but I can't think of a reason why it would not
work. You will definitely want to use one to handle the versioning issues
when you deserialize a stream using a later version of the assembly when it
was originally serialized with an earlier version of the stream.

"Henrik Skak Pedersen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I have a class which is beeing serialized/deserialized using the
> BinaryFormatter class. That has been working with no problems until I
> signed all my assemblies. Now I get a SerializationException when I try to
> Deserialize the class which has been serialized before the signing. So
> what is best practice in my situation?
>
> Do I have to convert all my saved classes or do I write a
> SerializationBinder to handle it runtime?
>
> If I delete all my data and run fra scratch it works fine until I compile
> my assembly. Then the assembly gets a new versioand it fails on the
> version. Why do I get this error now, i did'nt get it before I signed the
> assembly?
>
> Best regards
>
> Henrik Skak Pedersen
>



 
Reply With Quote
 
Henrik Skak Pedersen
Guest
Posts: n/a
 
      27th Jan 2005
Hi David,

Thank you very much for your email.

All my assemblies get a new version number everytime it get compiled. I am
using the following attribute:
[assembly: AssemblyVersion("1.0.*")]


I guess that is a problem then? Because my data is outdated very fast?

Best regards

Henrik Skak Pedersen

"David Levine" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I haven't tried to use a SerializationBinder to convert a stream from a
>unsigned to a signed assembly but I can't think of a reason why it would
>not work. You will definitely want to use one to handle the versioning
>issues when you deserialize a stream using a later version of the assembly
>when it was originally serialized with an earlier version of the stream.
>
> "Henrik Skak Pedersen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hello,
>>
>> I have a class which is beeing serialized/deserialized using the
>> BinaryFormatter class. That has been working with no problems until I
>> signed all my assemblies. Now I get a SerializationException when I try
>> to Deserialize the class which has been serialized before the signing. So
>> what is best practice in my situation?
>>
>> Do I have to convert all my saved classes or do I write a
>> SerializationBinder to handle it runtime?
>>
>> If I delete all my data and run fra scratch it works fine until I compile
>> my assembly. Then the assembly gets a new versioand it fails on the
>> version. Why do I get this error now, i did'nt get it before I signed the
>> assembly?
>>
>> Best regards
>>
>> Henrik Skak Pedersen
>>

>
>



 
Reply With Quote
 
David Levine
Guest
Posts: n/a
 
      28th Jan 2005

"Henrik Skak Pedersen" <(E-Mail Removed)> wrote in message
news:%23zoh%(E-Mail Removed)...
> Hi David,
>
> Thank you very much for your email.
>
> All my assemblies get a new version number everytime it get compiled. I am
> using the following attribute:
> [assembly: AssemblyVersion("1.0.*")]
>
>
> I guess that is a problem then? Because my data is outdated very fast?


It's not a problem so long as you use a SerializationBinder to return the
current type defined in the assembly. Of course, this assumes that the new
type is compatible with the old type. If not, then the type that changed
ought to implement the ISerializable interface and handle its own
serialization to/from the stream.

>
> Best regards
>
> Henrik Skak Pedersen
>
> "David Levine" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I haven't tried to use a SerializationBinder to convert a stream from a
>>unsigned to a signed assembly but I can't think of a reason why it would
>>not work. You will definitely want to use one to handle the versioning
>>issues when you deserialize a stream using a later version of the assembly
>>when it was originally serialized with an earlier version of the stream.
>>
>> "Henrik Skak Pedersen" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Hello,
>>>
>>> I have a class which is beeing serialized/deserialized using the
>>> BinaryFormatter class. That has been working with no problems until I
>>> signed all my assemblies. Now I get a SerializationException when I try
>>> to Deserialize the class which has been serialized before the signing.
>>> So what is best practice in my situation?
>>>
>>> Do I have to convert all my saved classes or do I write a
>>> SerializationBinder to handle it runtime?
>>>
>>> If I delete all my data and run fra scratch it works fine until I
>>> compile my assembly. Then the assembly gets a new versioand it fails on
>>> the version. Why do I get this error now, i did'nt get it before I
>>> signed the assembly?
>>>
>>> Best regards
>>>
>>> Henrik Skak Pedersen
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
specifying where to look for assembly when executing BinaryFormatter.Deserialize Ryan.Mohammed@gmail.com Microsoft C# .NET 1 7th Apr 2006 04:40 PM
BinaryFormatter.Deserialize fails when used with .net ActiveX =?Utf-8?B?YWxhZGRpbm0x?= Microsoft Dot NET 5 27th Sep 2005 04:01 PM
Assembly not found during BinaryFormatter.Deserialize Fruber Malcome Microsoft C# .NET 0 23rd Jun 2005 07:56 AM
BinaryFormatter.Deserialize after signing of assembly fails Henrik Skak Pedersen Microsoft C# .NET 2 27th Jan 2005 05:59 PM
BinaryFormatter fails to correctly serialize/deserialize dataset news.tweakdsl.nl Microsoft ADO .NET 0 1st Aug 2003 12:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:46 AM.