我有一个带有多个可见COM类的.NET DLL SigToolNet.DLL。它为本机C ++静态库FTDIVCPLIB引用了.NET DLL FTDIVcpLibNet.DLL包装器,该库又引用了第三方本机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.
包括FTDIVcpLibNet.dll在内的所有引用DLL都位于SigToolNet.DLL所在的同一文件夹中,该文件夹也是其注册地。
我尝试在3台不同的计算机上运行,但在Windows 7和Windows 10上均出现相同的失败结果。成功运行的开发系统正在运行Windows 10。
我还尝试使用Assembly Binding Log Viewer(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 ++ Redistribatable。在装有VS2019的计算机上,您已经拥有它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句