【发布时间】:2022-11-02 13:08:51
【问题描述】:
在未安装 .NET 3.5 的 Windows 10 或 11 机器上,调用 StrongNameSignatureVerificationEx() 要求 Windows 要求用户安装 .NET 3.5,为什么?是否可以绕过此对话框?或测试是否未安装 .NET 3.5?
using System;
using System.Runtime.InteropServices;
internal class Program {
[DllImport("mscoree.dll", CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "StrongNameSignatureVerificationEx")]
private static extern bool StrongNameSignatureVerificationEx(string wszFilePath,
byte fForceVerification,
ref byte pfWasVerified);
static void Main(string[] args) {
byte wasVerified = Convert.ToByte(false);
byte forceVerification = Convert.ToByte(true);
var bChecked = StrongNameSignatureVerificationEx(
@"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Collections.dll",
forceVerification,
ref wasVerified);
}
}
【问题讨论】: