vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

VS code debugging issue for azure powershell function - Omnisharp Json Rpc exception

Open lavibhatnagar opened this issue 3 years ago • 7 comments

Environment data

VS Code version: 1.68.0 C# Extension version: 1.25.0 Azure Core tools: v4 powershell version: 7

OmniSharp error

image

Steps to reproduce

  1. Create azure powershell function
  2. Put a breakpoint anywhere and hit F5
  3. See error

Expected behavior

Should be able to debug the function

Actual behavior

Exception of type Omnisharp.Extensions.JsonRpc.RpcErrorException was thrown

lavibhatnagar avatar Jun 16 '22 08:06 lavibhatnagar

We have tried the scenarios like

  • Uninstalling and Re-installing the C# version in VS Code Extensions
  • changing the C# version in VS Code Extensions
  • Restarting the VS Code

But getting the same exception for us too. Please give us a fix to this issue!

HariKrishna598 avatar Jun 16 '22 09:06 HariKrishna598

I am guessing the issue is that the C# extension is getting activated, but OmniSharp is unhappy that it can't find any C# code or projects in the workspace. But an OmniSharp log would probably be helpful if anyone from the OmniSharp team has the cycles to look at this...

gregg-miskelly avatar Jun 16 '22 20:06 gregg-miskelly

@HariKrishnaRajoli-MT @gregg-miskelly please follow this thread https://github.com/Azure/azure-functions-core-tools/issues/3076

lavibhatnagar avatar Jun 23 '22 18:06 lavibhatnagar

@lavibhatnagar I don't see an OmniSharp log in that issue either.

gregg-miskelly avatar Jun 23 '22 18:06 gregg-miskelly

@gregg-miskelly @HariKrishnaRajoli-MT this issue has been logged as bug by azure function.

https://github.com/microsoft/vscode-azurefunctions/issues/3223

lavibhatnagar avatar Jun 24 '22 07:06 lavibhatnagar

@gregg-miskelly a few users have reported this issue and provided some information in https://github.com/microsoft/vscode-azurefunctions/issues/3223. We haven't had much luck in our investigation and would appreciate any help you could provide! 😄

alexweininger avatar Jul 15 '22 15:07 alexweininger

I landed here by searching for possible solutions to the main problem "Omnisharp Json Rpc exception" occuring in VS Code. I tried everything possibly written here but could not get the resolution. I spent complete day in hope to resolve this and finally could do it. Here are the steps that helped me:

-prerequisites:

  1. launch.json
  2. tasks.json
  • configure launch.json { "name": "Attach to PowerShell Functions", "type": "PowerShell", "request": "attach", "customPipeName": "AzureFunctionsPSWorker", "runspaceId": 1, "processId": "${command:azureFunctions.pickProcess}", "preLaunchTask": "func start" //This should match with next tasks.json label }

  • configure tasks.json

{ "label": "func start", "type": "shell", "command": "func start", "problemMatcher": "$func-powershell-watch", "isBackground": true }

Hope it helps for someone facing the same problem.

Credit to -> https://stackoverflow.com/questions/67119522/how-to-start-azure-function-locally-and-attach-debugger-to-process-dynamically-v

tanieee28 avatar Oct 14 '22 15:10 tanieee28

@tanieee28 this works for me, modifying the tasks and launch json's.

erwinkramer avatar Feb 09 '23 10:02 erwinkramer

sweet, that worked for me, thank you @tanieee28 !

potatoqualitee avatar Mar 23 '23 08:03 potatoqualitee

I wish that the solution put forth by @tanieee28 worked for me, but unfortunately it did not. I seem to have to troubleshoot this issue with debugging every couple of weeks. Usually changing or adjusting something helps, but I have shot an entire day today just trying to run my code :( .

VSCODE: 1.81.1 C# ext: 2.0.376 PS ext: 2023.6.0 Az Func ext: 1.12.4 Az Func Core Tools: 4.0.5198 PowerShell: 7.3.6

Same error, although I only get it upon stopping the Azure Functions Core Tools. Very frustrating, and also this issue has been around a very long time.

dadlMilestone avatar Aug 18 '23 21:08 dadlMilestone