Running the console app

Open
#17,541 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp, powershell
Domain
cli

Research direction

Start by reproducing the failure with dotnet run from the project directory and compare it with running the .csproj through Visual Studio 2019. Investigate why the command-line entry point reports Win32Exception (5), then confirm that the documented command works or that a clear non-IDE workaround is available.

Written by the indexing model from the issue text.

Description

Problem encountered on https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/run
Operating System: windows

using Powershell ISE in Admin mode, I get this:

> PS F:\net6\myapp> dotnet run
dotnet : System.ComponentModel.Win32Exception (5): Access is denied.
At line:1 char:1
+ dotnet run
+ ~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (System.Componen...cess is denied. 
   :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo 
startInfo)
   at System.Diagnostics.Process.Start()
   at Microsoft.DotNet.Cli.Utils.Command.Execute(Action`1 processStarted)
   at Microsoft.DotNet.Cli.Utils.Command.Execute()
   at Microsoft.DotNet.Tools.Run.RunCommand.Execute()
   at Microsoft.DotNet.Tools.Run.RunCommand.Run(String[] args)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan 
startupTime, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

Using the default command line in admin mode, I get this:

F:\>cd net6\myapp

F:\net6\myApp>dotnet run
System.ComponentModel.Win32Exception (5): Access is denied.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at Microsoft.DotNet.Cli.Utils.Command.Execute(Action`1 processStarted)
   at Microsoft.DotNet.Cli.Utils.Command.Execute()
   at Microsoft.DotNet.Tools.Run.RunCommand.Execute()
   at Microsoft.DotNet.Tools.Run.RunCommand.Run(String[] args)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

F:\net6\myApp>

BUT, Using VS 2019 (Version 16.9.4), after opening the .csproj file, and running the project, I get this:

Hello World!

F:\net6\myApp\bin\Debug\net6.0\myApp.exe (process 17640) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

The web instructions state that I should get the result that came with using VS 2019, from the regular commandline, run in the project directory, but this fails. Is this known Issue? If yes, is there a workaround that does not involve the IDE?

Dominant language
C#
Stars
3.2k
Forks
1.3k
Avg merge
4d 1h
Merged PRs (30d)
235

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/sdk

All issues in dotnet/sdk

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.