`

strong-named

阅读更多

前段时间自己整理的一个有关strong-named assemblies的相关知识点。

What it the strong-named assembly?
A strong name consists of the assembly‘s identity:
Simple text name
Version number
Culture information
A public key and a digital signature


Benefits:
Strong names guarantee name uniqueness by relying on unique key pairs
Strong names protect the version lineage of an assembly.
Strong names provide a strong integrity check.

Public/Private key pair:
Create a public/private key pair
>sn -k myKeyPair.snk
Get the public key
>sn -p myKeyPair.snk myPublicKey.snk
View the public key
>sn -tp myPublicKey.snk

How to sign an assembly with a strong name:
Using the Assembly Linker (Al.exe)
>al /out:MyAssembly.dll MyModule.netmodule /keyfile:myKeyPair.snk
Using compiler options such /keyfile or /delaysign in C#
>csc /Keyfile:myKeyPair.snk test.cs
Using assembly attributes to insert the strong name information in code.
 [assembly: AssemblyKeyFile(“myKeyPair.snk")]

Delay Signing an Assembly:
An organization can have a closely guarded key pair that developers do not have access to on a daily basis. The public key is often available, but access to the private key is restricted to only a few individuals.
How to delay signing an assembly:
Obtain the public key portion of the key pair.
Annotate the source code for the assembly with two custom attributes
 [assembly:AssemblyKeyFileAttribute("myPublicKey.snk")]
 [assembly:AssemblyDelaySignAttribute(true)]
Compile the assembly
Turn off the verification of that signature.
     >sn –Vr myAssembly.dll
Using the actual strong name sign the assembly
     >sn -R myAssembly.dll myKeyPair.snk
Turn verification back on by executing the following command line:
    >SN -Vu myAssembly.dll


Publish and GAC:
If an assembly is to be accessed by multiple applications, the assembly must be placed into a well-known directory, which is called the global assembly cache (GAC).
 the GAC identifies assemblies using name, version, culture, public key, and CPU architecture.
You can't ever place a weakly named assembly into the GAC.
Install an assembly to GAC
    >gacutil -i hello.dll
Remove an assembly from GAC
    >gacutil –u hello.dll

分享到:
评论

相关推荐

    Borland Delphi 2005 Architect Update 3

    TFrame + TLabel + TRadioGroup = bad5.00 of 5 Closed9477 Delphi .NET assembly references with strong names5.00 of 5 Closed9254 Incorrect reference public key token included into Delphi8 strong-named ...

    Remote Sensing Digital Image Analysis-Fourth Edition

    Chapter 10 has been re-named. It was felt that there is too much confusion in the term Data Fusion to retain it as the title for material that is fundamentally concerned with thematic mapping from ...

    Synopse mORMot Framework 1.8 with help

    Server features to simple applications for hobbyists, or let experienced users develop scaling and strong service-based projects for their customers, with the advantages of native code and easy-to-...

    C#与.NET技术平台实战演练.part2

    14-2使用AttributeGlobalAttribute14-3自定义Attribute类14-3-1Attribute适用的元素14-3-2设计Attribute类14-3-3使用Attribute14-3-4Attribute编译的过程14-3-5使用positional参数与named参数14-3-6取得Attribute的...

    C#与.NET技术平台实战演练.part1

    14-2使用AttributeGlobalAttribute14-3自定义Attribute类14-3-1Attribute适用的元素14-3-2设计Attribute类14-3-3使用Attribute14-3-4Attribute编译的过程14-3-5使用positional参数与named参数14-3-6取得Attribute的...

    TeeChart Pro Activex Control v2018

    If you compile Strong Named Assemblies then imported ActiveX Controls must also be Strong Named. The Utilities folder contains a Strong Name compiled version of: \Utilities\VS.NET\Strong Named DLLs ...

    TeeChart2018ActiveX_0_2_9Eval3264

    If you compile Strong Named Assemblies then imported ActiveX Controls must also be Strong Named. The Utilities folder contains a Strong Name compiled version of: \Utilities\VS.NET\Strong Named DLLs ...

    TeeChart Pro Activex Control v5

    Strong Named DLL assemblies of TeeChart and TeeChart with Windows wrapper for use with Visual Studio.NET projects that require to be Strong Named. Changes to note: 1. VC++ developers should ...

    Camel.in.Action

    The Camel project was started in early 2007, but although it’s relatively young, Camel is already a mature open source project, available under the liberal Apache 2 license, and it has a strong ...

    HTML5&CSS3网页制作:HTML5文本格式化标记.pptx

    <p><strong>加粗文本</strong> 这个文本包含 下标文本。 这个文本包含 上标</sup> 文本。 <p>My favorite color is <del>blue</del> <ins>red! <p>My favorite color is <del>blue</del> <ins>red!;;;小任务 ;感

    D2D big data

    cost, but also high accuracy on deliveries of interesting and popular contents, as well as strong social impacts among friends. Nevertheless, the existing related studies are mostly confined to small-...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Table of Contents Header Files The #define Guard Header File Dependencies Inline Functions The -inl.h Files Function Parameter Ordering Names and Order of Includes Scoping Namespaces Nested Classes ...

    程序语言设计原理习题解答

    5.11 Named Constants 239 Summary • Review Questions • Problem Set • Programming Exercises ....242 Chapter 6 Data Types 251 6.1 Introduction 252 6.2 Primitive Data Types 253 6.3 ...

    云模型在文本挖掘应用中的关键问题研究

    CCJU not only has a strong ability to adapt to the different text features, the classification performance is also better than the traditional classifiers. (4) Rapid and unsupervised text clustering...

    C# Game Programming Cookbook for Unity 3D - 2014

    Acknowledgments xiii Introduction xv 1. Making Games the Modular Way 1 1.1 Important Programming Concepts.....................................2 1.1.1 Manager and Controller Scripts.......................

    CLR via C# 第4版 英文PDF

    Giving an Assembly a Strong Name 67 The global Assembly Cache 72 Building an Assembly That References a Strongly Named Assembly..74 Strongly named assemblies are tamper-Resistant 75 Delayed Signing ...

    JSP Simple Examples

    One of the strong features of java is that it is follows a OOPs concept, and one of the feature of OOP in java is that, we can assign a subclass object or variable to the variable of the superclass ...

    Professional C# 3rd Edition

    The Named Colors 646 Graphics Display Modes and the Safety Palette 646 The Safety Palette 647 Pens and Brushes 648 Brushes 648 Pens 649 xix Contents Drawing Shapes and Lines 650 Displaying Images 652 ...

    Bulletproof SSL and TLS,PDF , Ivan Ristic

    DNS-Based Authentication of Named Entities (DANE) 305 Trust Assertions for Certificate Keys (TACK) 309 Certification Authority Authorization 310 11. OpenSSL Cookbook . . . . . . . . . . . . . . . . . ...

    基于wifi的室内定位算法

    used to determine the location of the objects in the four APs(which are placed in the floor building)named building and the distance between tags and APs. To Hawk, Helicopter, Tag4M and WitagServer ...

Global site tag (gtag.js) - Google Analytics