C# Visual Studio代码C“;“不调试运行”;错误
我在Ubuntu 18.04上安装了Visual Studio代码1.56.2来开发Python 几天前,我安装了.NET Core for C#coding on Linux,这样我就可以用Visual Studio代码编写C#了 当我尝试运行“Program.cs”(hello world)应用程序时,我得到一个弹出窗口,错误是“您没有用于调试C#的扩展。我们应该在市场上找到C#扩展吗?” 我已经安装了“C#for Visual Studio代码(由OmniSharp.Microsoft提供支持)”,如下所示: 以下是我的工作区结构:C# Visual Studio代码C“;“不调试运行”;错误,c#,visual-studio-code,C#,Visual Studio Code,我在Ubuntu 18.04上安装了Visual Studio代码1.56.2来开发Python 几天前,我安装了.NET Core for C#coding on Linux,这样我就可以用Visual Studio代码编写C#了 当我尝试运行“Program.cs”(hello world)应用程序时,我得到一个弹出窗口,错误是“您没有用于调试C#的扩展。我们应该在市场上找到C#扩展吗?” 我已经安装了“C#for Visual Studio代码(由OmniSharp.Microsoft提供
如果您能帮我解决这个问题,我将不胜感激。请确保您的项目/解决方案根目录中名为
.vscode
的文件夹中既有launch.json
又有task.json
如果没有,您可以进入菜单Run
>addconfiguration…
它应该自动创建文件,但如果不能,下面是这些文件内容的示例(您需要调整到本地的fylesistem/project/version值)
tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "shell",
"args": [
"build",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net5.0/net.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
你能再次尝试关闭和打开VSCODE吗?@RodrigoRodrigues我刚刚尝试了关闭和打开VSCODE。我得到了同样的错误,这里是截图:谢谢你的详细回复。我必须手动创建一个launch.json文件,如您所示,才能通过此错误。现在我遇到了以下错误:“找不到调试类型'coreclr'的调试适配器描述符(扩展可能无法激活)”。这是我刚刚卸载并重新安装C#扩展的屏幕截图,正如这篇文章中所建议的,现在我发现错误“launch program'~/MyApp/bin/Debug/net5.0/net.dll'不存在。我刚刚开始工作!必须将launch.json“program”行更改为指向MyApp.dll,如下面的“program”:“${workspaceFolder}/bin/Debug/net5.0/MyApp.dll”,谢谢@Rodriguo的帮助!接受完成!