FileNotFound exceptions when debugging unit tests
When debugging MSTest unit tests in Rider, two exceptions are thrown while the test runner appears to be setting up. These exceptions are not thrown when debugging the app, nor are any exceptions thrown in Visual Studio 2022 when debugging the same tests.
The two exceptions:
Microsoft.VisualStudio.TestTools.CppUnitTestFramework.CppUnitTestExtension
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.CppUnitTestFramework.CppUnitTestExtension, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestTools.CppUnitTestFramework.CppUnitTestExtension, Culture=neutral, PublicKeyToken=null'
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestTools.CppUnitTestFramework.CppUnitTestExtension, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestTools.CppUnitTestFramework.CppUnitTestExtension, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginCache.CurrentDomainAssemblyResolve(Object sender, AssemblyResolveEventArgs args) in /_/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginCache.cs:line 513
at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformAssemblyResolver.AssemblyResolverEvent(Object sender, Object eventArgs) in /_/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyResolver.cs:line 74
at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginDiscoverer.GetTestExtensionsFromFiles[TPluginInfo,TExtension](String[] files, Dictionary`2 pluginInfos) in /_/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs:line 95Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter, Culture=neutral, PublicKeyToken=null'
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestPlatform.Extensions.MSAppContainerAdapter, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginCache.CurrentDomainAssemblyResolve(Object sender, AssemblyResolveEventArgs args) in /_/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginCache.cs:line 513
at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformAssemblyResolver.AssemblyResolverEvent(Object sender, Object eventArgs) in /_/src/Microsoft.TestPlatform.PlatformAbstractions/netcore/Runtime/PlatformAssemblyResolver.cs:line 74
at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginDiscoverer.GetTestExtensionsFromFiles[TPluginInfo,TExtension](String[] files, Dictionary`2 pluginInfos) in /_/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs:line 95These exceptions are not coming from my code, so why is Rider showing them in the first place? I don't use any C++ in this project. It's rather annoying having to resume execution from these two exceptions. And once I'm past them, test execution completes successfully with no errors.
Using Rider 2023.2.2, issue persists in 2023.3 EAP2
Please sign in to leave a comment.
Hello, prplecake ,
Regrettably, it looks like you've encountered a known issue: RIDER-92185 File Not Found Exception when debugging MS Unit tests in Rider. Please upvote it to indicate additional interest and click Watch to keep an eye on status updates.
As a workaround, I'd suggest turning off breaking on exception breakpoints from external code: