Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I strong name assemblies, when I have to manually turn of the Bypass-Feature?

The Microsoft Code Analysis encourages me to strong name all assemblies. But according to Microsoft I have to manually disable the "Bypass Feature" that they are checked.

So since .NET Framework version 3.5 Service Pack 1 strong names are not validated.

Why should I still sign my assemblies with a strong name?

Thanks! Stefan

like image 980
habakuk Avatar asked Mar 26 '14 11:03

habakuk


People also ask

Why a strongly named assembly is required?

What the error means. "Strong Name : Indicates that the reference has been signed with a key pair." If your current project's assembly is signed, then all your reference assemblies must also be signed. Failure to do so will result in this error.

How to turn off strong name validation?

You can turn off strong name validation for an assembly by using the sn.exe utility that ships with the framework. This is helpful if you want to add an assembly to the GAC that is delay signed.

What is strong name verification?

A strong name consists of the assembly's identity, simple text name, version number, and culture information (if provided)—plus a public key and a digital signature. Strong names serve to identify the author of the code.


1 Answers

So since .NET Framework version 3.5 Service Pack 1 strong names are not validated

Well, as a blanket statement that is not actually true. It is partially true, they are no longer validated iff the app runs in Full Trust and the assembly is stored in a trusted location. Local machine or Intranet zone.

At build time you have no reliable idea whatsoever where the assembly is ultimately going to be stored. You might have a deployment plan but plans like this tend to be overruled whenever it is convenient or necessary. This includes the need for a strong name when you need to store the assembly in the GAC. A work-around for a DLL Hell problem perhaps, something that may well need to be done years from now.

Pretty doggone inconvenient that such as solution isn't available because you didn't strong-name the assembly. And almost always too late to do anything about it by then since it requires rebuilding everything. Strong-naming is dead-simple, few good reasons to skip it. Or just suppress the message if you disagree with it, code analysis rules do fit the "have you considered this?" category of warnings. Gentle reminders of obscure details.

like image 163
Hans Passant Avatar answered Sep 23 '22 01:09

Hans Passant