strongname

Can strong naming cause problems with object serialization in C#?

ε祈祈猫儿з 提交于 2019-12-01 08:04:30
I serialize some configuration objects and store the result bytes within a database. new BinaryFormatter().Serialize(memoryStream, instance); Convert.ToBase64String(memoryStream.ToArray()); These objects will be deserialized later. new BinaryFormatter().Deserialize(memoryStream); It's possible, that the Application has some new assembly versions at the time of deserialization. In general it works well, but sometimes I get a file load exception: "The located assembly's manifest definition does not match the assembly reference." . The assemblies work all with strong naming, can that be the

Can strong naming cause problems with object serialization in C#?

我与影子孤独终老i 提交于 2019-12-01 06:47:25
问题 I serialize some configuration objects and store the result bytes within a database. new BinaryFormatter().Serialize(memoryStream, instance); Convert.ToBase64String(memoryStream.ToArray()); These objects will be deserialized later. new BinaryFormatter().Deserialize(memoryStream); It's possible, that the Application has some new assembly versions at the time of deserialization. In general it works well, but sometimes I get a file load exception: "The located assembly's manifest definition does

Quite special PublicKey in .NET core assemblies

不打扰是莪最后的温柔 提交于 2019-12-01 03:42:54
I've noticed that core .NET assemblies have PublicKey = 00000000000000000400000000000000. Not only it's shorter then those sn.exe allows to generate (min 384 bits) but also it has a lot of zeros. How to generate signing key with such a fancy public key? That's the ECMA Standard defined public key. It's to deal with three conflicting requirements: A mechanism that ensures that assemblies are signed by their creators and could not have been created by a fraudulent other party. That CLI be defined openly in such a way that other people are free to implement a version (Mono would be a real-life

SGEN, InternalsVisibleTo and assembly signing

天大地大妈咪最大 提交于 2019-12-01 00:38:22
I'm trying to do something a bit unusual... I have this class Foo : public class Foo { public Foo(string name) { this.Name = name; } internal Foo() { } public string Name { get; internal set; } public int Age { get; set; } } Notice the internal setter for Name, and the internal default constructor. This would normally prevent the XML serialization, but I also marked the XML serialization assembly as "friend" with InternalsVisibleTo : [assembly: InternalsVisibleTo("TestXML2008.XmlSerializers")] And I added a MSBuild task to pre-generate the serialization assembly : <Target Name="AfterBuild"

PFX/PKCS12 to SNK conversion for mono

萝らか妹 提交于 2019-11-30 20:26:35
This is follow up on Mono xbuild error CS1548 - key file has incorrect format Hi, I have an application that is written in C# using VS2008. At present we are porting this app to Mac using Mono. I have tried to extract the key from the pfx file. First I used `sn -pc key.pfx key.snk` this gave me an error of 'Failed to extract public key for key pair -- Keyset does not exist'. I then used `sn -p key.pfx key.snk` this created the snk file that I wanted. I then in mono selected the project Option > Assembly Signing When built the error 'key.snk is missing private key needed for signing'. I think I

Deserialize object into assembly that is now signed and versioned

◇◆丶佛笑我妖孽 提交于 2019-11-30 18:50:43
I used to serialize a treeview with the BinaryFormatter (c#). The Assembly that did just that and which contains the all the serializable classes has now a strong name and is signed and also got a new version number (however, implementation didn't change). When I try to deserialize the byte[] array, the line (TreeViewData)binaryFormatter.Deserialize(memoryStream); produces an ArgumentNullException. (Parametername: type) I thought the versionnumber is the problem, so I implemented an own Binder. I overwrote the BindToType method and made sure that the version is corrected and the correct type

sn.exe fails with Access Denied error message

倾然丶 夕夏残阳落幕 提交于 2019-11-29 17:27:31
问题 I get an Access is Denied error message when I use the strong name tool to create a new key to sign a .NET assembly. This works just fine on a Windows XP machine but it does not work on my Vista machine. PS C:\users\brian\Dev\Projects\BELib\BELib> sn -k keypair.snk Microsoft (R) .NET Framework Strong Name Utility Version 3.5.21022.8 Copyright (c) Microsoft Corporation. All rights reserved. Failed to generate a strong name key pair -- Access is denied. What causes this problem and how can I

snk vs. code signing certificate

拥有回忆 提交于 2019-11-28 21:18:52
In my organization we use snk files with strong names assemblies. We generate the snk ourselves. In addition we use a code signing signature on the binaries. We get the pfx from Verisign. What is the difference between these two processes? Isn't it a problem that the snk is not recevied from Verisign also? The snk and pfx are used for two different purposes. The snk is used for strong-naming, which uses a key pair to uniquely identify an assembly. The pfx is for code signing, which is a similar process but one that is intended to prevent malicious tampering with assemblies that are distributed

Anything wrong with NOT signing a .NET assembly?

≯℡__Kan透↙ 提交于 2019-11-28 15:41:29
One of my colleagues is very keen on signing assemblies. He literally tries to sign anything. Even when we use assemblies from Microsoft that are not signed, he will take the source code, sign it and then ask other developers to use his copy instead. I can understand the basic idea behind signing an assembly: to ensure a particular assembly is not compromised by some dodgy hacker. So if we are a software development company, we should sign our assembly before releasing some .NET library to our customers. However, we primarily develop web applications for our own use here, and I just can't see

Could not load file or assembly 'AssemblyName PublicKeyToken=null' or one of its dependencies

瘦欲@ 提交于 2019-11-28 10:55:13
{"Could not load file or assembly 'AssemblyName, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"AssemblyName, PublicKeyToken=null"} I'm getting the message in question as an InnerException.Message while trying to debug my application after signing the unsigned third-party assemblies it is using. The weird thing is that I have already signed the assembly shown in the message, the one that can't be loaded. What could the problem be here? How can I resolve this? EDIT Editing