`

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

分享到:
评论

相关推荐

    selenium-dotnet-strongnamed-2.44.0.zip

    标题 "selenium-dotnet-strongnamed-2.44.0.zip" 暗示这是一个针对.NET框架的Selenium库的特定版本,具有强命名(Strong-Named)的特性。Selenium是一个广泛使用的自动化测试工具,它允许开发人员编写脚本来模拟用户...

    windowsmain-dll

    - 使用强命名的DLL(Strong-Named DLLs),以防止版本冲突和假冒。 - 避免在全局目录下放置DLL,减少系统级的影响。 综上所述,"windowsmain-dll"可能是一个关键的系统或应用组件,涉及到Windows平台下的程序开发...

    WPE.zip_SysSettings 工具_The Match

    3. 强命名问题:如果程序集是强命名的(strong-named),那么它的哈希值必须与引用匹配。 4. 多目标框架问题:开发环境和运行环境的.NET Framework版本不一致。 为了解决这个问题,开发者通常需要执行以下步骤: 1...

    PB11.5特色讲解

    - **增强的.NET支持**:包括Strong-named assemblies,支持更多的.NET类库,提升了.NET环境下的兼容性和性能。 - **创新DataWindow**:DataWindow的改进允许开发人员创建更丰富、更具交互性的用户界面。 - **其他...

    c#生成和调研dllc#生成和调研dllc#生成和调研dll

    .NET Framework提供了强命名(Strong-Named)和合并(Assembly Binding Redirection)等机制来解决这些问题。 4. 错误处理:当DLL调用失败时,需要捕获并处理异常。了解`Platform Invoke (P/Invoke)`和`Interop ...

    开发人员应该了解的知识.txt

    - **Strong-Named Assemblies**:强命名程序集,通过签名确保程序集的唯一性和安全性,避免版本冲突。 - **Interface vs Class**:接口定义了一组方法和属性,不包含具体的实现;类则可以包含具体的方法实现和数据...

    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 ...

    隔离存储的使用(一个简单的演示)

    4. 强命名(Strong-Named)隔离:对于强命名的程序集,数据将被隔离在各自的命名空间内。 在C#中,使用`System.IO.IsolatedStorage`命名空间中的类来操作隔离存储。主要涉及以下核心类: - `IsolatedStorageFile`...

    注册程序集是什么意思?

    全局程序集缓存是.NET Framework中的一个特殊存储区域,它用于存放可以被多个应用程序域(AppDomain)共享的、强命名(Strong-Named)的程序集。GAC中的程序集具有唯一的标识,包括版本号、公钥和 Culture 信息,...

    3.6_Mod_Pract

    为了避免这种情况,应使用强命名的DLL(Strong-Named DLLs)和适当的版本控制策略。 9. **程序集**:在.NET Framework中,程序集(Assembly)是模块化代码的基本单元,它包含元数据和IL代码。一个程序集可以包含一...

    ICSharpCode.SharpZipLib 读取excel

    ICSharpCode.SharpZipLib 读取excel

    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 ...

    北京市房山区2021-2022学年第一学期高三期末英语答案.docx

    - “To build a strong connection with our family members...” 考查学生能否围绕主题展开论述,提出合理建议,并保持语言流畅。 通过以上解析,我们可以看出高三期末英语考试主要考查学生的语言基础、阅读理解...

    2015-2016学年牛津沪教版初中英语八年级(下)词汇练习【精品推荐】.pdf

    18. Because she is not strong enough for walking up mountains. (选择题,D for) - 知识点:"enough for doing sth."表示“足够做某事”。 以上是每道题目所涉及的英语语言点,这些知识点涵盖了词汇、语法、...

Global site tag (gtag.js) - Google Analytics