我无法编码的用户界面调试工作。 Visual Studio不会在断点上停止。一个简单的演示测试(仅在Excel工作表单元格中输入一个数字)在没有调试的情况下运行时会成功。但是在调试测试时,测试运行器会立即出错,而不会尝试进入测试类构造函数(如果提供)或测试方法。
报告的错误是:
Message: Unit Test Adapter threw exception:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..
我正在运行Visual Studio 2017,版本15.5.0。
Debug窗口的输出:
'testhost.x86.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\testhost.x86.exe'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.CoreUtilities.dll'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.PlatformAbstractions.dll'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.CrossPlatEngine.dll'. Cannot find or open the PDB file.
...
'QTAgent32_40.exe' (CLR v4.0.30319: TestAppDomain: 0bb1983f-0f53-41cc-b4ed-143874102a64): Unloaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel.dll'
'QTAgent32_40.exe' (CLR v4.0.30319: TestAppDomain: 0bb1983f-0f53-41cc-b4ed-143874102a64): Unloaded 'C:\VST\CodedUITestProject2\TestResults\abcdef_X#XXX## 2017-12-05 11_05_06\Out\CodedUITestProject2.dll'
The thread 0x1860 has exited with code 0 (0x0).
The thread 0x1dcc has exited with code 0 (0x0).
Exception thrown: 'System.Threading.ThreadInterruptedException' in mscorlib.dll
The thread 0x1cb0 has exited with code 0 (0x0).
The thread 0x2d54 has exited with code 0 (0x0).
The thread 0x2a40 has exited with code 0 (0x0).
The thread 0x1e04 has exited with code 0 (0x0).
The program '[8104] QTAgent32_40.exe: Program Trace' has exited with code 0 (0x0).
The thread 0x1714 has exited with code 0 (0x0).
The thread 0x265c has exited with code 0 (0x0).
The program '[8104] QTAgent32_40.exe' has exited with code 0 (0x0).
The thread 0x2d9c has exited with code 0 (0x0).
The thread 0xde4 has exited with code 0 (0x0).
The thread 0x3bc has exited with code 0 (0x0).
The thread 0x253c has exited with code 0 (0x0).
The program '[12012] testhost.x86.exe: Program Trace' has exited with code 0 (0x0).
The program '[12012] testhost.x86.exe' has exited with code 0 (0x0).
我已经尝试修复Visual Studio并安装最新的位等无济于事。我在两台不同的机器上遇到了这个问题。
答案 0 :(得分:1)
我使用最新的VS2017 15.5,它确实存在这个问题:
但在其他VS版本或VS 2017 15.4.4中,它确实没有这个问题。
由于我可以重新解决此问题,因此我会帮助您向产品团队报告此反馈:
如果可能,您可以添加评论并投票反馈。
<强>更新强>
我将VS2017更新为15.5.1版本,然后设置系统环境变量,如下面的屏幕截图所示:注意:您的VS2017将安装到路径,如C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017年\企业\ Common7 \ IDE。然后我重新启动VS IDE并重新打开测试项目,我现在可以很好地调试它。
由于最新的VS版本是15.5.2,请将其更新到最新版本。
答案 1 :(得分:1)
System.Diagnostics.Debugger.Launch();
System.Diagnostics.Debugger.Break();
然后调试模式开启!
答案 2 :(得分:0)
答案 3 :(得分:0)
我在将VS 2017升级到15.5.2之后开始遇到这个问题(我想我可能已经跳过了一次更新,因此可能已经在15.5.1中引入了。)
更新环境变量对我来说不起作用,所以我可以调试的唯一方法就是根据谢尔盖的回答在代码中显式启动调试器。
但是,Visual Studio Update 2017 15.5.3 已解决此问题。
答案 4 :(得分:0)