加载与引用 .NET DLL 位于同一文件夹中的引用的 .NET DLL 时"Not found"异常
"Not found" exception on loading referenced .NET DLL that is in same folder as referncing .NET DLL
我有一个.NET DLL SigToolNet.DLL有多个可见的COM类。 它引用本机C++静态库FTDIVCPLIB的.NET DLL FTDIVcpLibNet.DLL包装器,该包装器又引用第三方本机DLL ftd2xx.dll。 SigToolNet.DLL已成功注册32位
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的开发系统上运行时.exe应用程序TestHarness(在SigToolNet中引用COM可见类.DLL成功运行。 但是,当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:WindowsMicrosoft.NETFrameworkv4.0.30319clr.dll
Running under executable C:Vendor Testing HarnessEpic 2018 And BeyondEpicESigTestHarness.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 HarnessEpic 2018 And BeyondEpicESigTestHarness.exe.config does not exist.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:WindowsMicrosoft.NETFrameworkv4.0.30319configmachine.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++ Redisdistribaable 版本。在装有VS2019的机器上,您已经拥有了它。
- 加载与引用 .NET DLL 位于同一文件夹中的引用的 .NET DLL 时"Not found"异常
- VB.NET DLL中的C++DLL函数复制
- 是否可以编译使用 .NET DLL 和 GCC 的C++?
- 列出 C# 中的 non-.NET DLL 函数
- 如何为64位应用程序注册.NET DLL
- System.DllNotFoundException in .NET DLL
- 获取传递给子模块(C#.NET dll)中的主模块(VC++ exe)的参数
- 使用JNI集成java和.net dll
- 如何解决"原生DLL libmbusmaster.dll的问题不见了!请将 DLL 文件部署到与 mbusmaster.net.dll 相同的目录中。
- 如何更改.net dll的guid
- 动态加载.NET DLL包装C++DLL
- 使用 CoCreateInstance 从C++调用 COMVisible VB.Net dll
- .Net DLL vs C++ DLL
- 一个C++客户端无法使用我们新的 COM 注册的 .NET .dll加载,另一个客户端可以正常工作
- 如何在 Ubuntu 中将 c++ 编译为 Windows 的 .net Dll 文件
- Calling .NET DLL from Java
- 从本机C++调用.NET dll
- 从ASP调用后端.net dll.. NET Web api
- 从.Net Dll创建.Ocx文件
- 如何创建一个使用AFX库的混合模式CLR . net DLL