System.IO.FileLoadException:调试测试时无法加载文件或程序集'testhost

问题描述 投票:0回答:1

每次我尝试从Rider IDE调试单元测试时,测试执行都会失败,但有例外

System.IO.FileLoadException:无法加载文件或程序集“测试主机,文化=中性,PublicKeyToken =空”。找不到或加载特定文件。 (来自HRESULT的异常:0x80131621)文件名:'testhost,文化=中性,PublicKeyToken =空'

StackTrace:

at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Xunit.Runner.VisualStudio.VsTestRunner.GetAvailableRunnerReporters(IEnumerable`1 sources) in C:\Dev\xunit\xunit\src\xunit.runner.visualstudio\VsTestRunner.cs:line 711

仅在一个简单的项目中,错误发生在一个简单的项目中,调试器启动并正常工作。

在Visual Studio中调试正常。我希望能找到可能的解决方案的方向。

c# .net-core xunit rider
1个回答
0
投票
我通过“裸体”整个项目解决了这个问题:)

从磁盘上删除整个存储库后-克隆存储库-再次生成Visual Studio解决方案文件(我们不会将其保存在存储库中)-建立解决方案-运行测试-调试其中一项测试-调试器正常工作

[我从一些JetBrains论坛上找到了一个从点网位置删除Micrososft.AspNet.Core文件夹的建议,尽管建议的方法无效,但它使我意识到问题可能出在此特定的解决方案依赖项上。

© www.soinside.com 2019 - 2024. All rights reserved.