但是运行mcs -debug Startup.cs后,出现以下错误:Startup.cs(5,17): error CS0234: The type or namespace name `AspNet' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(6,17): error CS0234: The type or namespace name `AspNet' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(7,17): error CS0234: The type or namespace name `AspNet' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(8,17): error CS0234: The type or namespace name `Data' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(9,17): error CS0234: The type or namespace name `Extensions' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(10,17): error CS0234: The type or namespace name `Extensions' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(11,17): error CS0234: The type or namespace name `Extensions' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(12,17): error CS0234: The type or namespace name `Extensions' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(13,16): error CS0234: The type or namespace name `Models' does not exist in the namespace `palmtree'. Are you missing an assembly reference?Startup.cs(14,16): error CS0234: The type or namespace name `Services' does not exist in the namespace `palmtree'. Are you missing an assembly reference?Startup.cs(20,24): error CS0246: The type or namespace name `IHostingEnvironment' could not be found. Are you missing an assembly reference?Startup.cs(20,49): error CS0246: The type or namespace name `IApplicationEnvironment' could not be found. Are you missing an assembly reference?Startup.cs(39,16): error CS0246: The type or namespace name `IConfigurationRoot' could not be found. Are you missing an assembly reference?Startup.cs(42,39): error CS0246: The type or namespace name `IServiceCollection' could not be found. Are you missing an assembly reference?Startup.cs(62,31): error CS0246: The type or namespace name `IApplicationBuilder' could not be found. Are you missing an assembly reference?Startup.cs(62,56): error CS0246: The type or namespace name `IHostingEnvironment' could not be found. Are you missing an assembly reference?Startup.cs(62,81): error CS0246: The type or namespace name `ILoggerFactory' could not be found. Are you missing an assembly reference?似乎mono无法调试正确地编译Startup.cs.尝试设置调试程序时,是否有人收到此错误?还是有人可以在Mono,asp.net 5,kestrel,vs代码和OS X上使用断点?解决方案 调试Visual Studio代码和ASP.NET 5已在预览中,并且在此处 在Visual Studio Code中不支持调试ASP.NET 5的时间(在 任何平台).放心,我们正在努力将这些 在不久的将来给您带来的经验.参考: https://code.visualstudio.com/docs/runtimes/ASPnet5 您所指的Mono部分用于编译和附加到mono/.Net程序(而不是基于dnx ASP.NET的程序). ASP.NET 5应用程序是使用Roslyn编译器而不是Mono的mcs编译的. 调试Mono应用程序示例: 创建一个目录,cd进入该目录,然后键入code .以使用该目录启动VSCode.mkdir monoconsoletestcd monoconsoletestcode . 在VSCode中创建新文件 将其命名为program.cs 在编辑器中输入以下代码: using System;namespace consoleViaVSCode{ class MainClass { public static void Main (string[] args) { Console.WriteLine ("Hello VSCode!"); } }} 您可以在shell中编译并运行它,但是让我们创建一个tasks.json文件,以便我们可以通过Command Palette来实现. 创建一个tasks.json文件: 下一步是设置任务配置.为此,请使用F1打开命令面板",然后键入配置任务运行器",然后按Enter键将其选中.这将在.vscode文件夹中创建一个示例task.json文件.初始文件中包含大量示例.突出显示所有内容,将其删除并添加:{ "version": "0.1.0", "command": "mcs", "isShellCommand": true, "showOutput": "silent", "args": ["-debug", "program.cs"]} 现在,您可以通过task mcs在Command Palette之下执行一个任务,并且此任务将使用Mono的mcs编译器并带有'-debug'选项来构建program.cs,该选项将创建一个program.exe.mdb文件,该文件具有program.exe应用程序的调试符号.执行该任务,如果没有错误,文件窗格中将显示program.exe和program.exe.mdb`: 如果有任何错误,它们将显示在Output窗格(源代码窗格的右侧)中.现在,我们可以添加一个task来使用mono .Net运行时运行程序,并带有选项以等待调试器附加.注意:我会向您显示一个mono debugger task,但是运行这样的shell进程在VSC 0.10.1中被破坏了.并且您将把它包装在glup例程中...:-/等等... 在process.cs中的Console.Write....行上设置一个断点: 从您启动VSCode的外壳程序中:mono --debug --debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:5858 program.exe 返回VSCode: 单击Bug Icon,然后单击Config\Gear Icon,然后选择"C#mono"以生成默认的附加"配置.选择附加",然后单击绿色的开始"按钮: 然后您将达到断点: I'm pretty new to OS X (4 days with my new mac), and I am working on setting up an environment where I can debug my Asp.Net 5 web project locally with the debugger built into Visual Studio Code, specifically getting the breakpoint to work when attaching to mono.I followed these instructions for installing asp.net 5 and visual studio code. (http://docs.asp.net/en/latest/getting-started/installing-on-mac.html)I then installed yeoman, and scaffolded out an aspnet project.I ran commands dnu restore, dnu build, and dnx web.The project runs locally on Kestrel at localhost:5000 just fine. I can also attach it to mono via the VS Code debugger.The issue arises when I try to set breakpoints in the C# code. The debugger will not hit them.After doing some research I found that I needed to specify the Startup.cs file to mono as the one to debug. (https://code.visualstudio.com/Docs/editor/debugging)But after running mcs -debug Startup.cs, I get these errors:Startup.cs(5,17): error CS0234: The type or namespace name `AspNet' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(6,17): error CS0234: The type or namespace name `AspNet' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(7,17): error CS0234: The type or namespace name `AspNet' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(8,17): error CS0234: The type or namespace name `Data' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(9,17): error CS0234: The type or namespace name `Extensions' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(10,17): error CS0234: The type or namespace name `Extensions' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(11,17): error CS0234: The type or namespace name `Extensions' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(12,17): error CS0234: The type or namespace name `Extensions' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?Startup.cs(13,16): error CS0234: The type or namespace name `Models' does not exist in the namespace `palmtree'. Are you missing an assembly reference?Startup.cs(14,16): error CS0234: The type or namespace name `Services' does not exist in the namespace `palmtree'. Are you missing an assembly reference?Startup.cs(20,24): error CS0246: The type or namespace name `IHostingEnvironment' could not be found. Are you missing an assembly reference?Startup.cs(20,49): error CS0246: The type or namespace name `IApplicationEnvironment' could not be found. Are you missing an assembly reference?Startup.cs(39,16): error CS0246: The type or namespace name `IConfigurationRoot' could not be found. Are you missing an assembly reference?Startup.cs(42,39): error CS0246: The type or namespace name `IServiceCollection' could not be found. Are you missing an assembly reference?Startup.cs(62,31): error CS0246: The type or namespace name `IApplicationBuilder' could not be found. Are you missing an assembly reference?Startup.cs(62,56): error CS0246: The type or namespace name `IHostingEnvironment' could not be found. Are you missing an assembly reference?Startup.cs(62,81): error CS0246: The type or namespace name `ILoggerFactory' could not be found. Are you missing an assembly reference?It looks like mono cannot debug compile the Startup.cs properly. Is anyone else getting this error when trying to set up debugging? Or does anyone have breakpoints working with mono, asp.net 5, kestrel, vs code, and OS X? 解决方案 Debugging Visual Studio Code and ASP.NET 5 are in preview and at this time debugging ASP.NET 5 is not supported in Visual Studio Code (on any platform). Rest assured, we are working hard to bring these experiences to you in the near future.Ref: https://code.visualstudio.com/docs/runtimes/ASPnet5The Mono section that you are referring to is for compiling and attaching to a mono/.Net program (not an dnx ASP.NET-based one). ASP.NET 5 applications are compiled using the Roslyn compiler, not Mono's mcs.Debugging a Mono Application Example:Create a directory, cd into it and type code . to start VSCode using that directory.mkdir monoconsoletestcd monoconsoletestcode .Create a new file in VSCodeName it program.csEnter the following code into the editor:using System;namespace consoleViaVSCode{ class MainClass { public static void Main (string[] args) { Console.WriteLine ("Hello VSCode!"); } }}You could compile and run this in a shell, but let create a tasks.json file so we can do it via the Command Palette.Create a tasks.json file:The next step is to set up the task configuration. To do this open the Command Palette with F1 and type in Configure Task Runner, press Enter to select it.This will create a sample tasks.json file in the .vscode folder. The initial file has a large number of examples within it. Highlight it all, delete it and add:{ "version": "0.1.0", "command": "mcs", "isShellCommand": true, "showOutput": "silent", "args": ["-debug", "program.cs"]}Now you have one task that you can execute via task mcs down the Command Palette and this task will build your program.cs using Mono's mcs compiler with the '-debug' option that will create a program.exe.mdb file that has the debugging symbols for the program.exe application.So execute that task and if you have no errors, a program.exe and program.exe.mdb` will show up in the file pane:If you have any errors, they will show up in the Output pane (right of the source code pane).Now lets add a task to run your program with mono .Net runtime with the options for it to wait for a debugger to attach.Note: I would show you a mono debugger task but running a shell process like that is broken in VSC 0.10.1. and you would be to wrap it in a glup routine... :-/ so...In the process.cs, set a break point on the Console.Write.... line:From the shell that you started VSCode from: mono --debug --debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:5858 program.exeBack in VSCode:Click the Bug Icon and than the Config\Gear Icon and select "C# mono" to generate the default "attach" configuration. Select "Attach" and click green Start button:And you will hit your breakpoint: 这篇关于使用Visual Studio Code + ASP.NET 5 + Mono + Kestrel + OS X调试Web项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-31 15:41