HOW TO: Create an Assembly with a Strong Name

来源:互联网 发布:excel数据分析图 编辑:程序博客网 时间:2024/05/29 08:01
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
an class="baidu_ad">an> ank>HOW ank>TO: ank>Create an Assembly with a Strong Name

--------------------------------------------------------------------------------
The information in this article applies ank>TO:

Microsoft Visual Studio .NET Beta 2

--------------------------------------------------------------------------------

IN THIS TASK
SUMMARY
Prerequisites
Creating an Assembly with a Strong Name
REFERENCES


SUMMARY
Assemblies can be assigned a crypank>TOgraphic signature called a Strong Name, which provides Name uniqueness for the Assembly and prevents someone from taking over the Name of your Assembly (Name spoofing). If you are deploying an Assembly that will be shared among many applications on the same computer, it must have a Strong Name. This document describes ank>HOW ank>TO ank>Create an Assembly with a Strong Name.

back ank>TO the ank>TOp

Prerequisites
This article assumes that you have installed and are familiar with Visual Studio .NET.

back ank>TO the ank>TOp
Creating an Assembly with a Strong Name
Use the Strong Name ank>TOol (Sn.exe) that comes with the .NET Framework Software Development Kit (SDK) ank>TO generate a crypank>TOgraphic key pair.

The following command uses the Strong Name ank>TOol ank>TO generate a new key pair and sank>TOre it in a file called TestKey.snk:


sn -k Testkey.snk
Add the proper cusank>TOm attribute ank>TO your source for the compiler ank>TO emit the Assembly with a Strong Name. Which attribute you use depends on whether the key pair that is used for the signing is contained in a file or in a key container within the Crypank>TOgraphic Service Provider (CSP). For keys that are sank>TOred in a file, use the System.Reflection.AssemblyKeyFileAttribute attribute. For keys that are sank>TOred in the CSP, use the System.Reflection.AssemblyKeyNameAttribute attribute.

The following code uses AssemblyKeyFileAttribute ank>TO specify the Name of the file that contains the key pair.

NOTE : In Microsoft Visual Basic, the Assembly level attributes must appear as the first statements in the file.

Visual Basic .NET Code
Imports System
Imports System.Reflection

<Assembly:AssemblyKeyFileAttribute("TestKey.snk")>
C# Code
using System;
using System.Reflection;

[Assembly:AssemblyKeyFileAttribute("TestKey.snk")]
back ank>TO the ank>TOp
REFERENCES
For more information about the Strong Name ank>TOol (Sn.exe), see the following Microsoft .NET Framework ank>TOols Web site:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpank>TOols/html/cpgrfStrongNameutilitysnexe.asp
For more information about the .NET Framework SDK, see the following Microsoft Web site:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/nfstart/html/sdkstart.asp
For more information about global attributes, see the C# Programmer's Reference.

back ank>TO the

gzhanyunying/wangzhanyouhua/" title="seo,搜索引擎优化">seover="window.status='正文--ank>HOW ank>TO: ank>Create an Assembly with a Strong Name';return true">
<Strong><script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击