不能在windows上跳过.net强名称验证

本文关键字:net 强名称 验证 windows 不能 | 更新日期: 2023-09-27 18:02:20

我曾尝试在Win10和Win10上跳过。net强名称验证。这个主题,如何禁用强名称验证和此功能,请在x86和amd64环境中键入以下命令。

vcvarsall.bat amd64
sn /Vr *
vcvarsall.bat x86
sn /Vr *

但仍然收到投诉:

=== Pre-bind state information ===
LOG: User = US'Hauck
LOG: DisplayName = TestDll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b1cf2005f5cbe0bd (Fully-specified)
LOG: Appbase = file:///D:/myprojects/bin/
LOG: Initial PrivatePath = NULL
Calling assembly : TestDriver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b1cf2005f5cbe0bd.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from c:'WINDOWS'Microsoft.NET'Framework'v2.0.50727'config'machine.config.
LOG: Post-policy reference: TestDll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b1cf2005f5cbe0bd
LOG: Attempting download of new URL file:///D:/myprojects/bin/TestDll.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN 
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

在谷歌上搜索了很多之后,我仍然不知道如何跳过验证。

引用:

  1. 如何:在命令行上启用64位Visual c++工具集
  2. 绕过。net程序集的强名称验证
  3. 如何:禁用强名称旁路功能

不能在windows上跳过.net强名称验证

公钥令牌是程序集标识的一部分。这意味着如果你有两个程序集:

TestDriver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b1cf2005f5cbe0bd

TestDriver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

它们被程序集加载器视为完全不同的。在我看来,您在这里遇到的问题是您引用了程序集的强命名版本,但只有无符号版本可用。

如果你正在自己构建TestDriver,你需要确保你有公钥对的一半,它最终将被签名,然后在Visual Studio中程序集属性的签名页面上选中"延迟签名"框。这将构建一个具有公钥令牌的TestDriver版本,但它实际上没有签名。此时,必须禁用签名验证,但是一旦禁用,程序集应该加载。