Skip to content

How to Capture Unhandled SQL Tools Service Exceptions

Karl Burtram edited this page Nov 30, 2016 · 2 revisions

How to Capture SQL Tools Service Unhandled Exceptions

  1. Launch VS Code with mssql extension installed
  2. Determine the process ID for the Microsoft.SqlTools.ServiceLayer process. For example, this can be done with Task Manger on Windows or “ps –ef | egrep SqlTools” on Linux\Mac. This needs to happen before step 3 since each VS Code window has its own child Microsoft.SqlTools.ServiceLayer process.
  3. Launch a second VS Code window with the New Window command.
  4. Install C# VS Code extension https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp.
  5. Create a new folder and open it in VS Code.
  6. Add new file in folder with .cs extension and open the file. This will activate the C# extension and install the debugger binaries.
  7. Create a subdirectory .vscode and add a file launch.json with the below contents
{
    "version": "0.2.0",
    "configurations": [        
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command.pickProcess}",
            "justMyCode": false
        }
    ]
}
  1. Switch to debugger viewlet and click Start Debugging button
  2. Select the Microsoft.SqlTools.ServiceLayer process located in step 2
  3. In the first VS Code instance execute the crash repro scenario
  4. When the service instance crashes the unhandled exception should break in the second VS Code instance.
  5. Copy the $exception details and stack trace (from StackTrace propery) and provide it in the GitHub issue. Copying from the Debug Console usually works better than from Locals pane due to text truncation during copy.