如何禁用所有 .Net 程序集的强名称验证?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21763822/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:40:18  来源:igfitidea点击:

How to Disable Strong Name Verification for All .Net assembly?

.netconfigverificationstrongname

提问by user3307548

How to Disable .Net Strong Name Verification for All .Net assembly in system by config .net framework or IIS or project's config?

如何通过配置 .net 框架或 IIS 或项目的配置禁用系统中所有 .Net 程序集的 .Net 强名称验证?

http://nvea.host56.com/up/726daf2c9ee0.png(click for larger image)

http://nvea.host56.com/up/726daf2c9ee0.png(点击查看大图)

回答by user1376723

Try add it in regestry:

尝试在regestry 中添加它:

OS x32:

操作系统 x32:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\*,af24b530b87e22f1]

OS x64:

操作系统 x64:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\*,af24b530b87e22f1]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\*,af24b530b87e22f1]

and add it to your Web.config:

并将其添加到您的Web.config

<system.web>
   <hostingEnvironment shadowCopyBinAssemblies="false" />
</system.web>

回答by JoshVarty

To disable strong name validation for allassemblies on your machine you can run:

要对机器上的所有程序集禁用强名称验证,您可以运行:

sn.exe -Vr *

from a Developer Command Prompt for VS201*

来自 VS201* 的开发人员命令提示符

回答by agupta

Below Entries will work:

以下条目将起作用:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\*,af24b530b87e22f1]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\*,af24b530b87e22f1]

回答by serop

This is an exception I received:

这是我收到的一个例外:

Error Type: System.IO.FileLoadException
Error Message: Could not load file or assembly 'MyAssemblyName, Version=5.1.0.0,  Culture=neutral, PublicKeyToken=30b439e30eee46b4' or one of its dependencies.
Strong name  validation failed. (Exception from HRESULT: 0x8013141A)

This is a solution which worked for me to disable strong name validation for a particularassembly while testing it within totally signed service:

这是一个对我有用的解决方案,可以在完全签名的服务中测试它时禁用特定程序集的强名称验证:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\MyAssemblyName,30b439e30eee46b4]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\MyAssemblyName,30b439e30eee46b4]

You have to create those new keys in the registry, keys have no values under them. You can copy these two lines into .reg file, change assembly name and its guid and double-click it to merge into the Registry.

您必须在注册表中创建这些新键,键下没有值。您可以将这两行复制到 .reg 文件中,更改程序集名称及其 guid 并双击它以合并到注册表中。

Note: assembly name is your filename without .dll extension, exactly as it shows in the exception.

注意:程序集名称是没有 .dll 扩展名的文件名,与异常中显示的完全相同。

Then restart your app/service.

然后重新启动您的应用程序/服务。

I think the answers above with * instead of assembly name should also work.

我认为上面用 * 而不是程序集名称的答案也应该有效。