2

According to the documentation of this method, the first element of the returned string array should be the file name of the executing program, in other words, the .exe file, but if I execute the following code:

using System;

namespace main_namespace
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write(Environment.GetCommandLineArgs()[0]);
        }
    }
}

I get this output: C:\Code\C#\command_line_args_test\bin\Debug\netcoreapp3.1\command_line_args_test.dll

What is happening, shouldn't I get this: C:\Code\C#\command_line_args_test\bin\Debug\netcoreapp3.1\command_line_args_test.exe

  • 1
    that doesn't seem relevant – yaakov Mar 02 '20 at 21:28
  • 1
    Does this answer your question? The answer that is marked as solution should tell you everything you need. [VS2017 Compile NetCoreApp as EXE](https://stackoverflow.com/questions/44038847/vs2017-compile-netcoreapp-as-exe) – Max Play Mar 02 '20 at 21:43
  • 2
    i don't think this question is about how to compile it to exe, but about why it is not an exe. When you build you app, you get .dll file in your output folder. When you launch your project VS runs your program with 'dotnet YourApp.dll' command. This is why you are getting not an exe file in the path. – Yehor Androsov Mar 02 '20 at 21:56

0 Answers0