问题描述
这让我很伤心。我已经清除了有问题的软件包,卸载了软件包,重新安装,尝试添加 <packagereference>
,尝试使用 <targetFrameworks>
定位多个框架......所有这些,我仍然在运行时收到此错误.
我有一个 .NET Framework 4.8 项目正在使用的 .NET Standard 2.0 库。框架项目不引用任何 IdentityModel.Tokens/Jwt 对象。我已手动将程序集从包位置复制到有问题项目的 bin 文件夹中,但结果似乎没有改变。
融合日志
*** Assembly Binder Log Entry (1/7/2021 @ 11:38:12 AM) ***
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable REDACTED\REDACTED\bin\Debug\REDACTED.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: displayName = System.IdentityModel.Tokens.Jwt,Version=6.8.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file: REDACTED
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = REDACTED.exe
Calling assembly : REDACTED.Shared,Version=1.0.0.0,PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: REDACTED\REDACTED\bin\Debug\REDACTED.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.IdentityModel.Tokens.Jwt,PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///REDACTED/REDACTED/bin/Debug/System.IdentityModel.Tokens.Jwt.DLL.
LOG: Assembly download was successful. Attempting setup of file: REDACTED\REDACTED\bin\Debug\System.IdentityModel.Tokens.Jwt.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: System.IdentityModel.Tokens.Jwt,PublicKeyToken=31bf3856ad364e35
LOG: Binding succeeds. Returns assembly from REDACTED\REDACTED\bin\Debug\System.IdentityModel.Tokens.Jwt.dll.
LOG: Assembly is loaded in default load context.
解决方法
在对其进行额外检查后,结果证明引用 .NET Framework 项目的根项目文件(我们做的事情略有不同)需要对未加载的程序集的引用。
不知道为什么,但可能与 MVVM 以及使用根项目作为应用程序的包装器/驱动程序有关。