在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
创建强名称密钥文件
2 . 在命令提示符下,键入 sn -k Tutorial.snk,然后按 Enter。 概要 要在 GAC 中安装程序集,必须为程序集指定强名称。该名称是加密的哈希密钥或签名。这种强名称可确保正确的组件版本控制。这有助于防止具有相同名称的组件相互冲突或被消耗应用程序误用。 要求 本文假定您熟悉下列主题: • 大体熟悉 .NET 中的程序集 全局程序集缓存 注意:对于大多数用户,.NET 工具位于 C:\Program Files\Microsoft.NET\FrameworkSDK\Bin 中。键入以下 SN 命令前,可能需要在您的计算机上将与该路径类似的路径复制到 .NET bin 目录中。从命令提示符处键入 cd,右键单击以粘贴该路径,然后按 Enter,快速转至 SN 工具所在的目录。 键入以下内容: 将您的 .dll 文件拖到“Assembly”文件夹中。 using System.Reflection; using System.Runtime.CompilerServices; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // that is associated with an assembly. // [assembly: AssemblyTitle("")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // Version information for an assembly is made up of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values, or you can default the revision and build numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] // // To sign your assembly you must specify a key to use. See the // Microsoft .NET Framework documentation for more information about assembly signing. // // Use the following attributes to control that key is used for signing. // // Notes: // (*) If no key is specified, the assembly is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your computer. KeyFile refers to a file that contains // a key. // (*) If the KeyFile and the KeyName values are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP, that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the KeyFile is installed to the CSP and used. // (*) To create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile must be // relative to the project output directory which is // %Project Directory%\obj\<configuration>. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information about this. // [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("C:\\GACKey\\GACKey.snk")] [assembly: AssemblyKeyName("")]
许多应用程序都使用由多个应用程序共享的程序集。这些程序集通常由第三方开发商提供,安装在系统中的公用位置——全局程序集缓存中。默认情况下,系统在全局程序集缓存中查找每一个应用程序的程序集。必须拥有管理员的权限才能将程序集安装到全局程序集缓存中。安装在全局程序集缓存中的每一个程序集都必须拥有一个强名称。通过gacutil.exe可以访问全局程序集中的缓冲对象。Gacutil –i添加,gacutil –u移除,gacutil –l查询。C:\WINDOWS\assembly
2 . 在命令提示符下,键入 sn -k Tutorial.snk,然后按 Enter。 概要 要在 GAC 中安装程序集,必须为程序集指定强名称。该名称是加密的哈希密钥或签名。这种强名称可确保正确的组件版本控制。这有助于防止具有相同名称的组件相互冲突或被消耗应用程序误用。 要求 本文假定您熟悉下列主题: • 大体熟悉 .NET 中的程序集 全局程序集缓存 注意:对于大多数用户,.NET 工具位于 C:\Program Files\Microsoft.NET\FrameworkSDK\Bin 中。键入以下 SN 命令前,可能需要在您的计算机上将与该路径类似的路径复制到 .NET bin 目录中。从命令提示符处键入 cd,右键单击以粘贴该路径,然后按 Enter,快速转至 SN 工具所在的目录。 键入以下内容: 将您的 .dll 文件拖到“Assembly”文件夹中。 using System.Reflection; using System.Runtime.CompilerServices; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // that is associated with an assembly. // [assembly: AssemblyTitle("")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // Version information for an assembly is made up of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values, or you can default the revision and build numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] // // To sign your assembly you must specify a key to use. See the // Microsoft .NET Framework documentation for more information about assembly signing. // // Use the following attributes to control that key is used for signing. // // Notes: // (*) If no key is specified, the assembly is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your computer. KeyFile refers to a file that contains // a key. // (*) If the KeyFile and the KeyName values are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP, that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the KeyFile is installed to the CSP and used. // (*) To create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile must be // relative to the project output directory which is // %Project Directory%\obj\<configuration>. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information about this. // [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("C:\\GACKey\\GACKey.snk")] [assembly: AssemblyKeyName("")]
许多应用程序都使用由多个应用程序共享的程序集。这些程序集通常由第三方开发商提供,安装在系统中的公用位置——全局程序集缓存中。默认情况下,系统在全局程序集缓存中查找每一个应用程序的程序集。必须拥有管理员的权限才能将程序集安装到全局程序集缓存中。安装在全局程序集缓存中的每一个程序集都必须拥有一个强名称。通过gacutil.exe可以访问全局程序集中的缓冲对象。Gacutil –i添加,gacutil –u移除,gacutil –l查询。C:\WINDOWS\assembly |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论