开发者

Strong named assembly not working in my Visual C#

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(Str开发者_运维问答eam st)
        {
            BinaryFormatter bf = new BinaryFormatter();
            return (Type)bf.Deserialize(st);
        }

The application was doing right before I do this configureation.


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/


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.


Both of the responses were excellent.
Adding my 1 pence to it: This is called TYPE FIDELITY which is possible only through Binary serialization and not in XML or any other type of serialization.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜