首页 > 解决方案 > 带有 .NET Core 类库的 DLL Hell

问题描述

我正在构建一个 COM 库以将 SignalR 公开给非 NET 软件,但它有很多加载不同版本的引用,我什至浪费了很多时间来尝试获取所有内容的严格版本,但它只会破坏更多。由于 EXE 的 app.config 上的绑定重定向,在测试控制台应用程序上使用该库可以正常工作,但我无法将 .config 文件放在生产 EXE 上。我希望我有除此之外的其他选择。

实例(Assembly Binding Log Viewer)

*** Assembly Binder Log Entry  (29/06/2021 @ 14:02:43) ***

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:\Program Files (x86)\Sybase\PowerBuilder 11.5\PB115.EXE
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = System.Text.Json, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Sybase/PowerBuilder 11.5/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = PB115.EXE
Calling assembly : Microsoft.AspNetCore.SignalR.Protocols.Json, Version=5.0.7.0, Culture=neutral, PublicKeyToken=adb9793829ddae60.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Program Files (x86)\Sybase\PowerBuilder 11.5\PB115.EXE.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Text.Json, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Sybase/PowerBuilder 11.5/System.Text.Json.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Sybase/PowerBuilder 11.5/System.Text.Json/System.Text.Json.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Sybase/PowerBuilder 11.5/DotNET/bin/System.Text.Json.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Sybase/PowerBuilder 11.5/DotNET/bin/System.Text.Json/System.Text.Json.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Sybase/PowerBuilder 11.5/System.Text.Json.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Sybase/PowerBuilder 11.5/System.Text.Json/System.Text.Json.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Sybase/PowerBuilder 11.5/DotNET/bin/System.Text.Json.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Sybase/PowerBuilder 11.5/DotNET/bin/System.Text.Json/System.Text.Json.EXE.
LOG: Attempting download of new URL file:///C:/Users/user/Documents/project/bin/Release/System.Text.Json.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\user\Documents\project\bin\Release\System.Text.Json.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: System.Text.Json, Version=5.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
LOG: Attempting download of new URL file:///C:/Users/user/Documents/project/bin/Release/System.Text.Json/System.Text.Json.DLL.
LOG: Attempting download of new URL file:///C:/Users/user/Documents/project/bin/Release/System.Text.Json.EXE.
LOG: Attempting download of new URL file:///C:/Users/user/Documents/project/bin/Release/System.Text.Json/System.Text.Json.EXE.
LOG: All probing URLs attempted and failed.

标签: c#.net.net-coredllclass-library

解决方案


推荐阅读