views:

121

answers:

3

I have a project and I want to strong name the executable file. Using command-line compiling works well:

csc ... /keyfile:...

But I would like the IDE to do this, so I find this: in project property's `Signing' tab, there is a 'Sign the assembly' option. I tick it and direct to my key-pair file. After I lauch the debug, a FileNotFound exception shows up at an indifferent place: (my application uses serialization)

        protected override Type d(Stream st)
        {
            BinaryFormatter bf = new BinaryFormatter();
            return (Type)bf.Deserialize(st);
        }

The application was doing right before I do this configureation.

+2  A: 

I assume you are reading back data that was written with the unsigned application. That data has now become incompatible, the Deserializer can't match the types.

I'm not sure how to fix this (quickly), but maybe you can confirm this first by writing and reading with the signed application, that should work.

It is a good idea to keep all your serialized types in a separate assembly.

Henk Holterman
Thank you! That's it. The file was created and used before I made up my mind to use strong named assembly. Now I have compared the new one and the old one. They are apparently different. I didn't even know that files that used by strong named assembly are different from the normal.
fwoncn
+3  A: 

You will need to appropriately configure the Binder property of the BinaryFormatter. Here is an example of how to do this: http://spazzarama.wordpress.com/2009/06/25/binary-deserialize-unable-to-find-assembly/

Konamiman
+1  A: 
MSIL
Thank you! Your information is useful.
fwoncn