gpt4 book ai didi

c# - 如何在 .NET 中导入使用 sn.exe 生成的 .snk 文件?

转载 作者:行者123 更新时间:2023-11-30 13:29:01 28 4
gpt4 key购买 nike

我用这个命令创建了一个 key 文件:


sn.exe -k 2048 Build.snk

我想用 .NET 读入这个 key 。我还没有找到任何关于 .snk 格式的文档,所以我想知道 C# 中是否有办法读取 .snk 文件?

我问这个问题的最初原因是将 .snk 文件用于除签署程序集之外的其他目的。正如下面的答案之一所述,.snk 文件的目的实际上只是用于签署程序集。

最佳答案

在 MSDN 中找到提及 here .这是代码:


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
using (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();
}
}

关于c# - 如何在 .NET 中导入使用 sn.exe 生成的 .snk 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3095355/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com