Re: BinaryFormatter.Deserialize after signing of assembly fails by David
David
Fri Jan 28 04:23:10 CST 2005
"Henrik Skak Pedersen" <notavailable@nothing.com> wrote in message
news:%23zoh%23UHBFHA.2016@TK2MSFTNGP15.phx.gbl...
> 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" <noSpam12dlevineNNTP2@wi.rr.com> wrote in message
> news:uCNVdwFBFHA.3120@TK2MSFTNGP12.phx.gbl...
>>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" <notavailable@nothing.com> wrote in message
>> news:OMpiiVFBFHA.2016@TK2MSFTNGP15.phx.gbl...
>>> 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
>>>
>>
>>
>
>