"Not found" 加载与引用 .NET DLL 位于同一文件夹中的引用 .NET DLL 时出现异常
"Not found" exception on loading referenced .NET DLL that is in same folder as referncing .NET DLL
我有一个带有多个可见 COM class 的 .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 的开发系统上 运行ning 时,引用 COM 的应用程序 TestHarness.exe 在 SigToolNet.DLL 运行 中成功可见 class。但是,当 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.
包括 FTDIVcpLibNet.dll 在内的所有引用 DLL 都位于 SigToolNet.DLL 所在的同一文件夹中,这也是它的注册位置。
我已经在 3 台不同的计算机上尝试了 运行ning,在 Windows 7 和 Windows 10 上都出现了相同的失败结果。运行s 成功是 运行ning 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 的系统上 运行 成功,但在其他系统上却不成功。
可能您必须为您的 FTDIVCPLIB.dll 安装适当版本的 C++ Redistributable。在装有 VS2019 的机器上你已经拥有它了。
我有一个带有多个可见 COM class 的 .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 的开发系统上 运行ning 时,引用 COM 的应用程序 TestHarness.exe 在 SigToolNet.DLL 运行 中成功可见 class。但是,当 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.
包括 FTDIVcpLibNet.dll 在内的所有引用 DLL 都位于 SigToolNet.DLL 所在的同一文件夹中,这也是它的注册位置。
我已经在 3 台不同的计算机上尝试了 运行ning,在 Windows 7 和 Windows 10 上都出现了相同的失败结果。运行s 成功是 运行ning 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 的系统上 运行 成功,但在其他系统上却不成功。
可能您必须为您的 FTDIVCPLIB.dll 安装适当版本的 C++ Redistributable。在装有 VS2019 的机器上你已经拥有它了。