1

我有一个带有多个可见 COM 类的 .NET DLL SigToolNet.DLL。它引用了原生 C++ 静态库 FTDIVCPLIB 的 .NET DLL FTDIVcpLibNet.DLL 包装器,而后者又引用了第 3 方原生 DLL ftd2xx.dll。SigToolNet.DLL 已成功注册 32 位 regasm

C:\Release> regasm SigToolNet.dll /codebase
RegAsm : warning RA0000 : Registering an unsigned assembly with /codebase can cause your assembly to interfere with other applications that may be installed on the same computer. The /codebase switch is intended to be used only with signed assemblies. Please give your assembly a strong name and re-register it.
Types registered successfully

旁注,我不知道为什么它给我这个警告,因为 SigToolNet.dll 是代码签名的。在安装了 VS2019 的开发系统上运行时,引用 SigToolNet.DLL 中 COM 可见类的应用程序 TestHarness.exe 成功运行。但是,当 SigToolNet.DLL 安装在另一台计算机上时,我在运行时在调用 COM 可见方法之一 (DetectDevice) 的第二次调用时出现异常

Command DetectDevice failed
Error code: -2147024770
Desc: Could not load file or assembly 'FTDIVcpLibNet.dll' or one of its dependencies. The specified module could not be found.

所有引用的 DLL 包括 FTDIVcpLibNet.dll 都位于 SigToolNet.DLL 所在的同一文件夹中,该文件夹也是它的注册位置。

我尝试在 3 台不同的计算机上运行,​​在 Windows 7 和 Windows 10 上均出现相同的失败结果。它成功运行的开发系统正在运行 Windows 10。

我还尝试使用程序集绑定日志查看器 (fuslogvw.exe) 跟踪程序集加载失败

*** Assembly Binder Log Entry  (6/26/2020 @ 4:00:00 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Vendor Testing Harness\Epic 2018 And Beyond\EpicESigTestHarness.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = SigToolNet, Version=2020.0.0.3, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Vendor Testing Harness/Epic 2018 And Beyond/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = EpicESigTestHarness.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in the default load context.
LOG: Download of the application configuration file was attempted from file:///C:/Vendor Testing Harness/Epic 2018 And Beyond/EpicESigTestHarness.exe.config.
LOG: Configuration file C:\Vendor Testing Harness\Epic 2018 And Beyond\EpicESigTestHarness.exe.config does not exist.
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Vendor Testing Harness/Epic 2018 And Beyond/SigToolNet.DLL.
LOG: Attempting download of new URL file:///C:/Vendor Testing Harness/Epic 2018 And Beyond/SigToolNet/SigToolNet.DLL.
LOG: Attempting download of new URL file:///C:/Vendor Testing Harness/Epic 2018 And Beyond/SigToolNet.EXE.
LOG: Attempting download of new URL file:///C:/Vendor Testing Harness/Epic 2018 And Beyond/SigToolNet/SigToolNet.EXE.
LOG: All probing URLs attempted and failed.

我觉得这个日志令人困惑。它说它无法找到 SigToolNet.dll,但它似乎正在与 TestHarness.exe 相同的文件夹中寻找它。它应该在 C:\Release 中寻找它,这是 SigToolNet.dll 成功注册的地方。此外,报告的异常不是找不到 SigToolNet.dll,而是找不到 FTDIVcpLibNet.dll。第一个位置不应该是注册 SigToolNet.dll 的同一个文件夹吗?

我在 VS2019 中使用了远程调试,并且能够在调用第一个方法 Init 时在 SigToolNet 中设置断点和单步。但是由于调用执行之前的异常,第二次调用 DetectDevice 的断点永远不会发生。

所有 .NET DLL 都使用 .NET 4.8

我一直无法确定为什么它在开发 SigToolNet.dll 并安装了 VS2019 的系统上成功运行,但在其他系统上却没有。

4

1 回答 1

1

可能您必须为您的 FTDIVCPLIB.dll 安装适当版本的 C++ Redistribatable。在装有 VS2019 的机器上,您已经拥有它。

于 2020-06-27T10:53:38.997 回答