关于此错误有很多类似的帖子,不幸的是它们都没有帮助。
我已将解决方案项目升级到 .NET 4.8,然后发出命令来重新定位 nuget 包:
update-package -reinstall -ignoreDependencies
此后,单元测试失败并出现错误:
消息:System.IO.FileNotFoundException:无法加载文件或程序集“System.Runtime.InteropServices.RuntimeInformation,Version=4.0.2.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。该系统找不到指定的文件。---- System.IO.FileNotFoundException:无法加载文件或程序集“System.Runtime.InteropServices.RuntimeInformation,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。该系统找不到指定的文件
融合日志输出如下:
*** Assembly Binder Log Entry (7/24/2019 @ 2:20:44 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:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\testhost.x86.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/sources/Services/upgrade-net48/ProSynchronizationWorker.Tests/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = C:\Users\mike\AppData\Local\Temp\d21152b7-1ec9-47aa-88ab-181259a56531
LOG: AppName = d21152b7-1ec9-47aa-88ab-181259a56531
Calling assembly : MongoDB.Driver.Core, Version=2.7.2.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\sources\Services\upgrade-net48\ProSynchronizationWorker.Tests\bin\Debug\ProSynchronizationWorker.Tests.dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.0 redirected to 4.0.2.0.
LOG: Post-policy reference: System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/sources/Services/upgrade-net48/ProSynchronizationWorker.Tests/bin/Debug/System.Runtime.InteropServices.RuntimeInformation.DLL.
LOG: Attempting download of new URL file:///C:/sources/Services/upgrade-net48/ProSynchronizationWorker.Tests/bin/Debug/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.DLL.
LOG: Attempting download of new URL file:///C:/sources/Services/upgrade-net48/ProSynchronizationWorker.Tests/bin/Debug/System.Runtime.InteropServices.RuntimeInformation.EXE.
LOG: Attempting download of new URL file:///C:/sources/Services/upgrade-net48/ProSynchronizationWorker.Tests/bin/Debug/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.EXE.
LOG: All probing URLs attempted and failed.
Run Code Online (Sandbox Code Playgroud)
我尝试了一些建议
从 Fusion 日志来看,它会查看 GAC 但没有找到程序集(我可以确认 v.4.0.2.0 位于 GAC_MSIL 中)。
我怎样才能摆脱这个错误?
小智 7
我遇到了同样的问题, CAD bloke对类似问题的回答提供了对我有用的解决方案 :
具体来说,我必须从项目中删除System.Runtime.InteropServices.RuntimeInformation NuGet 包。事实证明它包含在 .Net >= 4.71 中,因此无需显式添加该包。
| 归档时间: |
|
| 查看次数: |
5613 次 |
| 最近记录: |