-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot debug .NET Framework 4.7.2 unit test from "Debug Test" code lens in VSCode #4361
Comments
This is expected, though the error message could certainly be better. The problem is the debugger is being told to launch for |
@gregg-miskelly I have already changed the |
Is your unit test process 32-bit? |
Is there a quick way to determine if the unit test process is 32 or 64 bit? Or should I just run it and look for the process in the Task Manager? |
I am definitely not an expert on unit test projects. So there could be a better way, but I would either check task manager or have your code log the value of |
I think that isn't the right process. That sounds like a part of VS Code, where your code is probably running in some unit test runner process, though maybe I am wrong. At any rate, this extension only supports debugging x64 processes. So this is your problem. You may be able to fix this by either setting 'Platform' to 'x64' in your project file, or maybe clearing 'Prefer32Bit'. Though I don't know a ton about nunit, so maybe it doesn't respect that. |
I'll update my question. I do have I've never heard of <PropertyGroup>
<TargetFramework>net472</TargetFramework>
<Platform>x64</Platform>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> |
Yup. |
Ok I added both of those things and I have the same problem. I'm really not sure why my unit test process that gets kicked off (which I'm assuming is the NUnit3TestAdapter package) is running in 32 bit. It hasn't done that in the 1.5+ years that I've been working in this repository, it just started recently. What determines the platform that the test adapter process runs at? Is it Omnisharp? Or the C# package? Or VSCode? If anyone has anymore information about any of this, I'm willing to try any sort of fix. I'd also like to know if anyone can reproduce this problem. Thanks for your help so far @gregg-miskelly! |
As an update, one of my friends is able to reproduce this exact same issue on his computer. From what I can deduce, there seems to be something wrong with the "Debug Test" code lens. Here's a minimum setup that both of us used to reproduce this issue: Following this process will NOT produce the error:
But this process WILL produce the error:
It seems like "Debug Test" is doing something differently that running a full |
Just to loop back around on this, I updated my installation of Visual Studio 2019 to the latest version (v16.9.2), which upgraded the build engine to I'm not sure exactly what the issue was, but it must be something with Visual Studio's installation alongside VSCode that was causing some issues. Or it was a bug in something was was installed with Visual Studio, maybe the initial release of .NET 5? Either way I hope this helps someone 😊 |
Nevermind this is still an issue 🙁 |
After multiple weeks encountering this issue, I found a working solution. Fix : Create a "My_Project.runsettings" file specifying "x64" and refer to it in the settings.json of you solution with "omnisharp.testRunSettings":"Path_To_My_File\My_Project.runsettings" Explanation : The "0x80131c30" signify that the debugger and the debuggee doesn't target the same platform. (https://www.hresult.info/FACILITY_URT/0x80131C30) In my case my project was targeting x64 and the debugger was launching with x86 (this can be seen using trace log on omnisharp, and you'll see it is using testhost.net47.x86.exe). In my case I needed to specify to launch the debugger in x64. In Visual Studio, this can be done thanks to the property "TargetPlatform" of the runSettings file (https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2019#the-runsettings-file). Fortunately, we can specify in omnisharp the runSettings file thanks to #3573. Unfortunately, this option was not made visible through intellisense (#3916). Don't know why using .Net Core projects I didn't had the issue. Hope this helps ! |
thanks |
@ToucanSuperMan420 unfortunately, this did not work for me. When I add in the |
1 ½ years later, new job, new laptop, and this is still an issue. Can reproduce locally with .NET Framework 4.5 using SDK csproj format:
|
This is because you are trying to run tests in an x86 process, and VS Code only supports debugging 64-bit processes. |
@gregg-miskelly the issue is that no where am I explicitly saying "run these tests in x86". I'm not sure where in the process I'm doing something wrong.
I have all of the setting mentioned above, Are you able to reproduce this or is everything working for you? |
@RLPHRE I believe you want to configure your project to use a .runsettings file. Documentation: link I think the .runsettings file you want should look like this: <?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
</RunSettings> |
@gregg-miskelly ok I'm able to get this working. Though I think there is something actionable in this ticket. Should OmniSharp's documentation be updated to reflect that when you're using .NET Framework with tests you MUST have a In this scenario OmniSharp doesn't seem to work "out of the box" like it does for .NET Core/.NET. Does the documentation already reflect this and I just missed it? |
@RLPHRE I updated https://github.com/OmniSharp/omnisharp-vscode/wiki/Desktop-.NET-Framework and https://github.com/OmniSharp/omnisharp-vscode/wiki/How-to-run-and-debug-unit-tests with better information. If there are other spots you think the documentation should be updated, let me know. I also fixed the debugger to put up a better error message when it is asked to launch an x86 .NET Framework program. |
Issue Description
When I click on the "Debug Test" code lens above my NUnit tests, I get the following error popup in the corner of VSCode:
![image](https://user-images.githubusercontent.com/47531470/105527072-3ac6b580-5cb1-11eb-8a6c-e8320f98b0ab.png)
I can debug my code just fine from the VSCode debug menu, breakpoints are hit. I'm also able to debug tests form the "Debug Test" code lens in other projects that are .NET Core. Appears to be only a .NET Framework error.
This error happens when running VSCode as Administrator and as a normal user (tested both.) I tried disabling all other extensions and only using the
ms-dotnettools.csharp
extension, but I'm getting the same error.Steps to Reproduce
.vscode\settings.json
with the following setting:Expected Behavior
Test runs and breakpoint is hit.
Actual Behavior
Debugging appears to start, but then stops and gives this error:
> Error processing 'configurationDone' request. Unknown Error: 0x80131c30
Logs
OmniSharp log
[info]: OmniSharp.DotNetTest.VSTestManager read: {"MessageType":"ProtocolVersion","Payload":1}
[info]: OmniSharp.DotNetTest.DebugSessionManager Debug session started.
[info]: OmniSharp.DotNetTest.DebugSessionManager Debug session ended.
C# log
Environment information
VSCode version: 1.52.1
C# Extension: 1.23.8
Dotnet Information
.NET SDK (reflecting any global.json): Version: 5.0.100 Commit: 5044b93829Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.100\
Host (useful for support):
Version: 5.0.0
Commit: cf258a14b7
.NET SDKs installed:
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.300 [C:\Program Files\dotnet\sdk]
2.1.301 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
2.2.207 [C:\Program Files\dotnet\sdk]
3.1.300 [C:\Program Files\dotnet\sdk]
3.1.301 [C:\Program Files\dotnet\sdk]
5.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Extensions
The text was updated successfully, but these errors were encountered: