I'm running vscode version 1.73.1
I have the following extensions installed on a new VM that sits behind a corporate proxy:
Microsoft C# v1.25.2
Azurite v3.20.1
Azure Functions v1.9.0
I have a C# Azure Functions project that I'd like to debug.
My tasks.json file contains the following:
{
"type": "func",
"dependsOn": "build (functions)",
"options": {
"cwd": "${workspaceFolder}/bin/Debug/net6.0"
},
"command": "host start --dotnet-isolated-debug",
"isBackground": true,
"problemMatcher": "$func-dotnet-watch"
}
The launch.json is as follows:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
I click the debug icon from the sidebar menu and choose "Run and Debug - Attach to .Net Functions"
The function app is then build and starts. The VM is slow so it takes more than 60 seconds for the function app to start. During that time VS code pops up a message to say is it slow. However, the function app does start and the http endpoints are presented in green text.
I then see the following presented in the terminal window:
Azure Functions .NET Worker (PID: 12116) initialized in debug mode.
Waiting for debugger to attach... Host lock lease acquired by instance
ID '00000000000000000000000083B41702'. A debugger was not attached
within the expected time limit. The process will continue without a
debugger. Worker process started and initialized.
I don't see any text in the "Debug Console"
I am able to call the http endpoint and a successful response is returned, but the breakpoint does not break!
If I run the same solution in vs code directly on my laptop, then the debugger is attached. Problem is, I need to debug on the corporate VM because the code selects from an on-prem sql db.
So, I guess there must be some difference between the two configurations of vs code / extensions or perhaps the corporate proxy is causing a problem?
Not sure which text file this gets saved to but was able to resolve by extending the timeout in the workspace preferences section:
I increased from the default of 60 (seconds) to 180
I am trying to use the C# extension in VS code to debug a program, however when I try to run without debugging I get the message "Cannot launch program setting the 'outFiles' attribute might help".
My launch.json file
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
}
My C# code
using System;
// Class declaration
class Geeks {
// Main Method
static void Main(string[] args) {
}
}
As noted in comments you are using the launch.json for a Node project.
The Visual Studio Code C# extension can generate the assets you need to build and debug.
You can generate them through the Command Palette (View > Command Palette) by typing '.NET', and running .NET: Generate Assets for Build and Debug. This command will generate the necessary launch.json and tasks.json configuration files (under the .vscode folder).
See docs and debugging
I am trying to debug a simple "Hello world" application in VS Code, however, when I press Ctrl + F5, it gives me the following error:
If I manually change the path in launch.json from:
${workspaceFolder}/bin/Debug/insert-target-framework-here/insert-project-name-here.dll
To:
"${workspaceFolder}/bin/Debug/netcoreapp2.1/test.dll"
It does work, however before it was working fine without me manually typing the path. Also, I have noticed that VS Code no longer asks to rebuild assets like it did before:
So far I have tried the following:
Uninstalled VS Code, then .NET Core 2.1, deleted the VS Code extension folder from %USER%\.vscode\ , re-installed VS Code, then .NET Core 2.1, and then the C# extension (C# for Visual Studio Code (powered by OmniSharp)).
When the VS Code starts, it does download the "OmniSharp" package successfully, but still, no prompt to rebuild assets when I open a C# file. Debugging gives the same issue as before.
Here is the launch.json:
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
}
And the tasks.json:
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet build",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
I found a solution that worked for me.
My VS Code was giving me the same error message, and what I did to fix it was:
- Press the combination Ctrl + Shift + P
- Restart Omnisharp
- Then it asks if you want to add missing files for build.
- Click Yes.
After this I was able to debug my app.
Hope it works for you!
Visit your \bin\Debug\netcoreapp3.1 in your project folder (That you open in VS)
Go to launch.json file in VS:
Replace:
"program": "${workspaceFolder}/bin/Debug//.dll",
With:
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/CSharp.dll",
In may case, the project is called CSharp. Watch out.
I had a the same error. The debugger was looking for the .dll file in ${workspaceFolder}/bin/Debug/netcoreapp3.1/myApp.dll but the file was located in ${workspaceFolder}/bin/MCD/Debug/netcoreapp3.1/tradeAppl.dll
After changing the launch.json file to read
...
"program": "${workspaceFolder}/bin/MCD/Debug/netcoreapp3.1/tradeAppl.dll",
...
I was able to debug the application without any problems.
Since you have :".dll" taged with "<" and ">", it means that you have give it a value.
The easiest way to do it is to open the project in VSCode and use find&replace to replace the:
with your project name which I do believe its: "test" as per the .dll name
Configure your Launch.json like this Gist
And there is no need to Tasks.json , you can Press F5 to build or configure it your self to which command should be run in default shell when you press F5
// "program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/csharp_multi_threads.dll",
You need to change the program value as it reminded
I switched to MS Visual Studio, since I did not find any other solutions.
-Right Click on Project Name And Click on Reveal in Explorer
-Copy Url In Explorer After Folder Name
For Example My Folder Address is
D:\IOT\Projects\LWSIOT_WebApiWM2\LWSIOT_WebApiWM2\LWSIOT_WebApiWM2\bin\Debug\netcoreapp3.1\LWSIOT_WebApiWM2.dll
And In Launch.json :
${workspaceFolder}/LWSIOT_WebApiWM2/LWSIOT_WebApiWM2/bin/Debug/netcoreapp3.1/LWSIOT_WebApiWM2.dll
-Paste in Launch.json on "Program":"<Your_Address>"
-Click On Debug And Its OK
In launch.json , replace :
"program": "${workspaceFolder}/Api/bin/Debug/netcoreapp3.1/Api.dll",
with:
"program": "${workspaceFolder}/Api/bin/linux/Debug/netcoreapp3.1/Api.dll"
Since I was running code in Linux machine so I should have provided Linux Folder' path
Must be an issue with the path to the dll in the program property of the launch.json file.
In my case, it still contained the old .net core framework version after the version upgrade.
I'v been recently trying to experience with Heroku, to host a c# (Console application) Discord.Net (API) project.
I deployed the entire project using the Heroku CI and then added the Procfile and the package.json with
$git commit
and it responded with "nothing added to commit but untracked files present."
With that I went to the site only to find out that my Worker Dyno that I declared on my profile is missing.
Can someone help me figure out why is the Dyno missing although I declared it?
Procfile:
worker: node Program.cs //The file containing the script
Package:
{
"name": "Test",
"description": "Test",
"version": "0.0.0",
"main": "Program.cs",
"scripts": {
"start": "node Program.cs"
},
"dependencies": {
"discord.net": "1.0.2"
}
}
The procfile MUST'NT contain any extensions... the debugger misses it otherwise.
Unlike the explenation that heroku provides...
Once I removed all extensions it was recognized as a dyno.
I have a 'Hello World' Kestrel server generated by Yeoman (as described here).
yo aspnet
When I run the site via the command line everything work well:
dotnet run
If it's run through Visual Studio Code though bootstrap.css, jquery.js and bootstrap.js don't load (404).
Looking at the F12 tools, they are actually coming from different locations. When run via dotnet run they come from https://ajax.aspnetcdn.com/..., but when run through Visual Studio Code the browser is looking for them in a local folder ~/lib/....
a. Why are the files being sourced differently depending on how I run the site?
b. How do I fix this?
Thanks
When you run it from command line, it runs in production mode (no ASPNETCORE_ENVIRONMENT variable set. When you run it from Visual Studio it sets the ASPNETCORE_ENVIRONMENT to Development.
Inside your Razor files, you have a <environments> section which controls which files are served in which production mode. Depending on your environment/OS, you need to set the variable differently. i.e. in Linux you'd need to run ASPNETCORE_ENVIRONMENT=Development dotnet run.
As for the reason why you get 404 when running in development mode, you probably need to copy over the wwwroot folder to your output directory, with this entry in your project.json.
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"copyToOutput":
[
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
Though usually it should be necessary to add wwwroot to copyToOutput