Kri*_*ram 4 c# .net-core visual-studio-code vscode-debugger
我是 DotnetCore 和 MS 编程的新手。随着 MS 对平台中立性的新推动,我有兴趣尝试一下,看看它是否像它承诺的那样工作。也就是说,我什至无法从 VSCode 在 Windows 上的 DotNetCore 上运行 helloworld 程序。在我的命令提示符和 VisualStudio 2019(我的 mac 的 VS Studio for mac)上,一切似乎都运行良好。真正的压力似乎在 Windows 10 中的 VSCode 上。如果可以,我将不胜感激
我收到的错误是“找不到 coreclr 类型的调试适配器”。不管我做什么,我最终都会遇到这个错误。1. 安装 Dotnet core 3.0 2. 设置指向 C:\Program Files\dotnet\sdk\3.0.100\Sdks 的 MSBuildSDKsPath 环境变量 3. 多次重启机器
什么都行不通。这是示例代码以及我的launch.json。
using System;
namespace OOPExample
{
public struct Dimensions {
public double Length { get; }
public double Width { get; }
public Dimensions(double length, double width) {
Length = length;
Width= width;
}
public double Diagonal => Math.Sqrt(Length * Length + Width * Width);
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine($"Hello World - {new Dimensions(10.0, 15.0).Diagonal}");
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的launch.json
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/OOPExample.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我从命令提示符执行 dotnet build 和 dotnet run 时,一切都很好
dotnet 构建:
C:\Users\Krishnan\Projects\DotNet\OOPExample> dotnet build
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 12.86 ms for C:\Users\Krishnan\Projects\DotNet\OOPExample\OOPExample.csproj.
OOPExample -> C:\Users\Krishnan\Projects\DotNet\OOPExample\bin\Debug\netcoreapp3.0\OOPExample.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.77
Run Code Online (Sandbox Code Playgroud)
dotnet 运行:
PS C:\Users\Krishnan\Projects\DotNet\OOPExample> dotnet run
Hello World - 18.027756377319946
Run Code Online (Sandbox Code Playgroud)
如果您想知道我是如何创建这个项目的,它只不过是一个简单的 dotnet new 控制台命令。所以没什么好看的
小智 5
也许这可以帮助遇到此问题的人:过去一周我已解决了两次此错误。
第一次通过卸载/重新安装 OmniSharp C# 扩展。
第二次通过将 VSCode 更新到最新版本。
我还没有弄清楚这两件事是否相关,但我在 OmniSharp 或 VSC 发行说明中没有看到任何关于它的具体内容。
| 归档时间: |
|
| 查看次数: |
7537 次 |
| 最近记录: |