System.IO.FileLoadException: Could not load file or assembly 'testhost, when debugging tests

0

Everytime I try to debug unit tests from Rider IDE, test execution fails with an exception

System.IO.FileLoadException: Could not load file or assembly 'testhost, Culture=neutral, PublicKeyToken=null'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621) File name: 'testhost, Culture=neutral, PublicKeyToken=null'

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

Error happens only in one complicated project, with simple projects debugger starts and works properly.

Debugging in Visual Studio works ok. I would appreciate a hint of the direction to look for possible solution.

c#
.net-core
xunit
rider
asked on Stack Overflow Feb 14, 2020 by Basin

1 Answer

0

I got solved this issue by "nuking" whole project :)

After removing whole repository from the disk
- Clone repository back
- Generate Visual Studio solution file again (we don't keep them in repository)
- Build solution
- Run tests
- Debug one of the test - Debugger works properly

I found from some JetBrains forums an advise to remove Micrososft.AspNet.Core folder from dotnet location, while advised approach didn't work, it gave me an idea that the problem can be with this particular solution dependencies.

answered on Stack Overflow Feb 15, 2020 by Basin

User contributions licensed under CC BY-SA 3.0