You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Rider调试单元测试时提示找不到Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.resources

Rider调试MSTest单元测试时的异常中断问题

异常现象

调试单元测试时,Rider会先后触发两个已处理的异常,每次都需要手动按F5才能继续运行;不调试时测试可正常完成:

COMException

System.Runtime.InteropServices.COMException (0x80070490): Element not found. (Exception from HRESULT: 0x80070490)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.VSInstallationUtilities.ISetupConfiguration.GetInstanceForCurrentProcess()
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.VSInstallationUtilities.get_VSInstallPath()

FileNotFoundException

Could not load file or assembly
'Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.resources, Version=14.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a' 
or one of its dependencies. The system cannot find the file specified.

已执行的操作

  • 测试项目中已安装NuGet包:
    <PackageReference Include="Microsoft.VisualStudio.TestPlatform" Version="14.0.0" />
    
  • 项目bin文件夹中存在相关.dll文件,但无法找到所需的.resources文件
  • 问题近一个月出现,疑似与Rider最新更新有关,此前有同类未解决问题

解决方法尝试

  • 关闭指定异常的调试中断:
    打开Rider设置(File > Settings),进入Build, Execution, Deployment > Debugger > Exception Settings,分别搜索System.Runtime.InteropServices.COMException和System.IO.FileNotFoundException,取消勾选这两个异常的「Thrown」选项,调试时就不会再中断在这些已处理的异常上。
  • 更新TestPlatform NuGet包版本:
    14.0.0版本较老旧,可能和新版Rider存在兼容性问题。尝试升级到稳定的高版本(如17.x系列),修改项目文件中的包引用后执行dotnet restore:
    <PackageReference Include="Microsoft.VisualStudio.TestPlatform" Version="17.8.0" />
    
  • 手动补充resources文件:
    下载对应版本的Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapterNuGet包,解压后找到en-US目录下的Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.resources.dll,将其复制到测试项目bin目录的en-US子文件夹中。
  • 重置Rider项目配置:
    删除项目根目录下的.idea文件夹,重启Rider并重新加载项目,排除配置文件损坏导致的异常拦截问题。

内容的提问来源于stack exchange,提问作者Developer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 16:48:22