question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot debug .NET Framework 4.7.2 unit test from "Debug Test" code lens in VSCode

See original GitHub issue

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

Error processing ‘configurationDone’ request. Unknown Error: 0x80131c30

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

  1. Create a .NET Framework 4.7.2 test project:
    <Project Sdk="Microsoft.NET.Sdk">
    
        <PropertyGroup>
    	    <TargetFramework>net472</TargetFramework>
    	    <Platform>x64</Platform>    
    	    <IsPackable>false</IsPackable>
        </PropertyGroup>
    
        <ItemGroup>
    	    <PackageReference Include="NUnit" Version="3.12.0" />
    	    <PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
    	    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
        </ItemGroup>
    
    </Project>
    
    using NUnit.Framework;
    
    namespace tests
    {
        [TestFixture]
        public class Tests
        {
    	    [Test]
    	    public void Test1()
    	    {
    		    Assert.That(true, Is.EqualTo(true));
    	    }
        }
    }
    
  2. Create a .vscode\settings.json with the following setting:
    {
        "csharp.unitTestDebuggingOptions": {
    	    "type": "clr"
        }
    }
    
  3. Set a breakpoint in the test and click the “Debug Test” code lens above the test function.

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":"TestSession.Connected","Payload":null}
[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

none

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: 5044b93829

Runtime 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
Extension Author Version
auto-using Fudge 0.7.15
Bookmarks alefragnani 12.1.4
bracket-pair-colorizer CoenraadS 1.0.61
cake-vscode cake-build 1.0.0
code-spell-checker streetsidesoftware 1.10.2
csharp ms-dotnettools 1.23.8
debugger-for-chrome msjsdiag 4.12.11
docker-explorer formulahendry 0.1.7
docomment k–kato 0.1.20
EditorConfig EditorConfig 0.16.4
gitlens eamodio 11.1.3
jupyter ms-toolsai 2020.12.414227025
markdown-pdf yzane 1.4.4
ng-template Angular 11.1.0
npm-intellisense christian-kohler 1.3.1
openapi-lint mermade 1.2.0
plantuml jebbs 2.14.1
plantuml jkeys089 1.8.1
python ms-python 2021.1.502429796
python tht13 0.2.3
remote-containers ms-vscode-remote 0.155.1
remote-ssh ms-vscode-remote 0.62.0
remote-ssh-edit ms-vscode-remote 0.62.0
remote-ssh-explorer ms-vscode-remote 0.56.0
remote-wsl ms-vscode-remote 0.52.0
rust rust-lang 0.7.8
stylelint shinnn 0.51.0
swagger-viewer Arjun 3.0.1
vscode-custom-css be5invis 4.0.1
vscode-docker ms-azuretools 1.9.1
vscode-icons vscode-icons-team 11.1.0
vscode-markdownlint DavidAnson 0.38.0
vscode-npm-script eg2 0.3.13
vscode-remote-extensionpack ms-vscode-remote 0.20.0
vscode-test-explorer hbenl 2.19.5
vscode-todo-highlight wayou 1.0.4
vscode-typescript-tslint-plugin ms-vscode 1.3.3
vscode-xml redhat 0.14.0
vscode-yaml redhat 0.14.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:22 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
gregg-miskellycommented, Aug 23, 2022

@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.

1reaction
Toucan4Lifecommented, Jun 24, 2021

After multiple weeks encountering this issue, I found a working solution.

Fix : Create a “My_Project.runsettings” file specifying “<TargetPlatform>x64</TargetPlatform>” 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 !

Read more comments on GitHub >

github_iconTop Results From Across the Web

unable to debug tests on visual studio 2022
Not being able to debug any test (in a specific test project). Look at your output window and select output from: tests. If...
Read more >
Cannot Run or Debug C# tests with CodeLens in VSCode
I have run it using the dotnet test command, the .NET Core Test Explore Plugin and VS2022, and these work as expected. This...
Read more >
Debugging .NET Framework in VS Code - DEV Community ‍ ‍
Want to use VS Code but have a Framework based project? ... Let's also test our IIS Express setup quickly before loading into...
Read more >
Getting Started: .NET Framework with Visual Studio > xUnit.net
In this article, we will demonstrate getting started with xUnit.net, showing you how to write and run your first set of unit tests....
Read more >
Tutorial: Test a .NET class library using Visual Studio Code
In this article · Prerequisites · Create a unit test project · Add a project reference · Add and run unit test methods...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found