c# - WinExe 的 VSCode tasks.json 和 launch.json 依赖于 dll
问题描述
我正在尝试 - 为了学习 - 为 VSCode 编写 tasks.json 和 launch.json 来构建这个项目:ExportableDataGrid
有两个 .csproj - 一个构建一个“库”,另一个构建一个依赖于库的“WinExe”。
构建成功,但调试器不启动 .exe 并出现以下错误:
Error processing 'configurationDone' request. Unknown Error: 0x80131c30
使用此 cli:
dotnet build Mm.ExportableDataGrid\Mm.ExportableDataGrid.csproj
dotnet build Mm.ExportableDataGrid.Wpf\Mm.ExportableDataGrid.Wpf.csproj
我收到这些错误:
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csf.csproj]
C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\MainWindow.xaml.cs(13,13): error CS0103: The name 'InitializeComponent' does not exist in the current context [C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csproj]
C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\MainWindow.xaml.cs(52,13): error CS0103: The name 'dataGrid' does not exist in the current context [C:\Users\userid\C-Sharp Prp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csproj]
launch.json 和 tasks.json 都在一个根文件夹中,其中包含来自 github 存档的两个文件夹。
启动.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Custom .NET Launcher",
"type": "clr",
"request": "launch",
"preLaunchTask": "buildExe",
"program": "${workspaceFolder}/Mm.ExportableDataGrid.Wpf/bin/Debug/Mm.ExportableDataGrid.Wpf.exe",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
}
]
}
任务.json
{
"version": "2.0.0",
"tasks": [
{
"label":"buildDll",
"type":"shell",
"command":"C:/\"Program Files (x86)/\"Microsoft Visual Studio\"/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
"presentation":{
"clear":true
},
"args":[
"Mm.ExportableDataGrid\\Mm.ExportableDataGrid.csproj",
"/t:Build",
"/p:Configuration=Debug",
"/p:Platform=\"AnyCPU\""
]
},
{
"label":"buildExe",
"type":"shell",
"command":"C:/\"Program Files (x86)/\"Microsoft Visual Studio\"/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
"presentation":{
"clear":true
},
"dependsOn":"buildDll",
"args":[
"Mm.ExportableDataGrid.Wpf\\Mm.ExportableDataGrid.Wpf.csproj",
"/t:Build",
"/p:Configuration=Debug",
"/p:Platform=\"AnyCPU\""
]
}
]
}
尽管阅读很多,但我无法弄清楚这里发生了什么。
- 如何调试 0x80131c30 错误?
- 为什么我会收到 CS5001 错误?
另外 - 我能够在没有调试的情况下运行,没有问题。似乎是附加调试器的问题。
解决方案
在遇到问题数周后,我才发现了这个问题。
解决方法是创建一个指定“x64”的“My_Project.runsettings”文件,并在您的解决方案的 settings.json 中使用“omnisharp.testRunSettings”:“Path_To_My_File\My_Project.runsettings”引用它
有关详细说明,请参阅我在 github 上的回答:https ://github.com/OmniSharp/omnisharp-vscode/issues/4361#issuecomment-858540496
推荐阅读
- google-calendar-api - Google 日历插入事件 API - 执行代码时不会出现提醒
- android - 我想显示进度对话框,直到从 Firebase 数据库收到数据
- java - 控制流语句。目标钱应该经过多少年
- regex - 使用正则表达式获取一些数据,但不是全部
- c# - 如何为 ASP.NET MVC 应用程序设置基本路径或 ApplicationPath
- java - 如何在处理中使用鼠标单击?
- bash - 使用变量更改 Shell 脚本目录
- go - 两种算法,我机器上的结果相同,测试结果不同
- c# - 使用 try-catch 的系统异常
- io - 内核如何跟踪哪些进程从中断接收数据?