StrongNameKeyPair 类

定义

注意

Strong name signing is not supported and throws PlatformNotSupportedException.

封装对公钥或私钥对的访问,该公钥或私钥对用于为强名称程序集创建签名。

C#
public class StrongNameKeyPair : System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
C#
[System.Obsolete("Strong name signing is not supported and throws PlatformNotSupportedException.", DiagnosticId="SYSLIB0017", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public class StrongNameKeyPair : System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
C#
[System.Serializable]
public class StrongNameKeyPair
C#
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class StrongNameKeyPair : System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
继承
StrongNameKeyPair
属性
实现

示例

下面的代码示例演示如何使用 -k 开关 () 打开通过运行 Sn.exe (强名称工具) 生成的 Company.keys 文件,从文件中读取公钥,并在控制台窗口中显示密钥。

C#
using System;
using System.IO;
using System.Reflection;

class snkX
{

    public static void Main()
    {
        // Open a file that contains a public key value. The line below
        // assumes that the Strong Name tool (SN.exe) was executed from
        // a command prompt as follows:
        //       SN.exe -k C:\Company.keys
        FileStream fs = File.Open("C:\\Company.keys", FileMode.Open);

        // Construct a StrongNameKeyPair object. This object should obtain
        // the public key from the Company.keys file.
        StrongNameKeyPair k = new StrongNameKeyPair(fs);

        // Display the bytes that make up the public key.
        Console.WriteLine(BitConverter.ToString(k.PublicKey));

        // Close the file.
        fs.Close();
    }
}

// Output will vary by user.
//
//  00-24-00-00-04-80-00-00-94-69-89-78-BB-F1-F2-71-00-00-00-34-26-
//  69-89-78-BB-F1-F2-71-00-F1-FA-F2-F9-4A-A8-5E-82-55-AB-49-4D-A6-
//  ED-AB-5F-CE-DE-59-49-8D-63-01-B0-E1-BF-43-07-FA-55-D4-36-75-EE-
//  8B-83-32-39-B7-02-DE-3D-81-29-7B-E8-EA-F0-2E-78-94-96-F1-73-79-
//  69-89-78-BB-F1-F2-71-0E-4E-F4-5D-DD-A4-7F-11-54-DF-65-DE-89-23-
//  91-AD-53-E1-C0-DA-9E-0C-88-BE-AA-7B-39-20-9C-9B-55-34-26-3B-1A-
//  53-41-31-00-04-00-00-01-00-01-00-9D-F1-EA-14-4C-88-34-26-3B-1A-
//  2D-D7-A0-AB-F6-7E-B7-24-7F-87-DF-3E-97

构造函数

StrongNameKeyPair(Byte[])
已过时.

初始化 StrongNameKeyPair 类的新实例,同时从 byte 数组生成密钥对。

StrongNameKeyPair(FileStream)
已过时.

初始化 StrongNameKeyPair 类的新实例,同时从 FileStream 生成密钥对。

StrongNameKeyPair(SerializationInfo, StreamingContext)
已过时.

初始化 StrongNameKeyPair 类的新实例,从序列化数据生成密钥对。

StrongNameKeyPair(String)
已过时.

初始化 StrongNameKeyPair 类的新实例,同时从 String 生成密钥对。

属性

PublicKey
已过时.

获取密钥对的公钥或公钥标记的公共部分。

方法

Equals(Object)
已过时.

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()
已过时.

作为默认哈希函数。

(继承自 Object)
GetType()
已过时.

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()
已过时.

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()
已过时.

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

IDeserializationCallback.OnDeserialization(Object)
已过时.

在整个对象图形已经反序列化时运行。

ISerializable.GetObjectData(SerializationInfo, StreamingContext)
已过时.

用重新实例化当前 SerializationInfo 对象所需的所有数据设置 StrongNameKeyPair 对象。

适用于

产品 版本 (已过时)
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5 (6, 7, 8, 9)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

另请参阅