7

I am trying to set up a web api using ASP.NET Core on OS X. I have set up my environment correctly (I think) and I'm able to build and run my application using dotnet build from the terminal, and I'm able to start debugging from Visual Studio Code with breakpoints working as expected. My problem is that I receive an error when trying to query my Sqlite database using EF core. EF core is not really important here, because when I am debugging and trying to find out what the error is, I don't get any stack trace. When I step over the failing code the debug console prints:

Exception thrown: 'System.InvalidOperationException' in Microsoft.EntityFrameworkCore.dll
Loaded '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.0/System.Diagnostics.StackTrace.dll'. Cannot find or open the symbol file.
Loaded '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.0/System.Reflection.Metadata.dll'. Cannot find or open the symbol file.
Loaded '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.0/System.IO.MemoryMappedFiles.dll'. Cannot find or open the symbol file.
Loaded '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.0/System.IO.UnmanagedMemoryStream.dll'. Cannot find or open the symbol file.

A lot of these Cannot find or open the symbol file. are printed at startup as well. I have checked that the files are at the location specified, and that there shouldn't be any read access problem (having started vs code with sudo code . and even done a sudo chmod 777 * in the folder in question).

So, any ideas why the symbols aren't loaded?

Erik
  • 714
  • 11
  • 29
  • It sounds like you did not install Visual Studio Code and/or .NET Core correctly. Can you edit your post to describe the steps you used to install? You should not have needed to do the chmod at all. (I'm running VSCode on OSX happily for some time now.) – JasCav Aug 09 '16 at 01:57
  • Standard install using homebrew like described here: https://www.microsoft.com/net/core#macos. VS Code installed using standard installer. The sudo and chmod were just shots in the dark, I assumed that the pdb files' location was unreachable by the running process or something like that. – Erik Oct 14 '16 at 23:10
  • I followed the same instructions (OSX) and have the exact same problem. I don't want to look at a wall of warnings every time I debug – Phil Ricketts Dec 17 '16 at 17:34

2 Answers2

4

Ran into the same issues running VS Code on a Windows 10 VM.

The resolution I found was to add a "debugType": "portable" setting to the buildOptions section of my project.json file.

Mine looks like this:

"buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "debugType": "portable"
}

Debugging in VS Code isn't that bad actually.

Brendan Green
  • 11,676
  • 5
  • 44
  • 76
  • Hey, that worked! And you are right, it's not a bad debugger at all. – joshmcode Oct 09 '16 at 08:35
  • This apparently happens by default for OSX and Linux according to this: https://learn.microsoft.com/nb-no/dotnet/articles/core/tutorials/using-on-macos – Erik Oct 14 '16 at 23:05
  • 5
    This is already the standard now as of 1.1. Still the same problem. – Phil Ricketts Dec 17 '16 at 17:35
  • @Erik the linked tutorial I interpret as saying that `"debugType":"portable"` will "generate portable PDB files (this happens by default on Mac OSX and Linux)" on Windows. The OP is looking for symbols for the .NETCore dlls to help with debugging. Reporting the symbol file as missing isn't helpful. – David Clarke Feb 13 '17 at 08:53
0

I think you have confused what VSCode is saying it cannot load. It isn't saying that it can't load the DLL. 'Symbol' files have a .PDB extension. In order to debug an error generated by a DLL, a debugger needs the corresponding symbol file, so changing the permissions on the DLL won't make the error go away if the PDB file is not there.

I've just started using VSCode on a Mac and from what I can see, you don't get the PDB files if you install dotnet core with Homebrew (which is what they recommend) and I see similar messages when I startup the debugger. That doesn't stop me from debugging my own code because there is a PDB file generated with my DLL. It would only cause a problem if you needed to debug something going wrong inside dotnet core itself.

  • Same scenario, but VSCode is still unable to go through the code of installed packages e.g. Nancy, EF, etc. I can only see my code and all the other statements in the stack trace is "No name". Any clues? – Devesh Khandelwal Aug 24 '16 at 13:24
  • I don't think I'm confused :) If the dll's weren't loading the process would crash and burn way faster. I am able to debug, set breakpoints and step through code as I stated in the question. It's just that when the output window is supposed to print the stack trace, it can't find the symbols needed. – Erik Oct 14 '16 at 23:30
  • @Erik I'm having the same problem. What was your solution? Install symbols by some other install method? – Phil Ricketts Dec 17 '16 at 17:35
  • @PhilRicketts So far I haven't found a fix for this, unfortunately. I do however get the exception details in the variables window, but the stacktrace is still not displaying in the output window. – Erik Dec 18 '16 at 11:03