1

I'm a beginner to coding in C#.

I was following a YouTube video on how to develop a console application in Visual Studio. At the end of the video, the guy finds the executable, moves it to desktop, and runs it Here's the tutorial I followed for context (if needed). However, this doesn't work out for me...

The output executable is contained in a folder with JSON, dll, and pdb files... I don't really know what these do. Here are the files in the same folder as the executable. When I try to run the program without those other files in the folder, say by copying the executable to desktop, it won't run.

If someone could shed light on something I'm missing, that'd be great.

dbm94
  • 21
  • 4
  • 2
    This is not really a programming problem, its basic computer skills, youtube video comprehension and following instructions. Obviously if you do exactly what the youtube says it would likely work (maybe)... Even if it didn't, this is not how we ask questions here unfortunately. There is a level of quality we require and a level of due diligence and effort you need to deliver. Take a look at this [ask], and also consider a [mcve]. Also note we don't watch youtube or follow links to answer a question (usually) – TheGeneral Jun 29 '21 at 07:57
  • If you want a "single file executable" you need to deploy as one. See https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file – Fildor Jun 29 '21 at 07:58

2 Answers2

4

You need to compile your console app to one File executable

use self contained option: enter image description here

on Visual studio 2019:

enter image description here

Emilis Vadopalas
  • 1,019
  • 2
  • 14
  • 22
0

The guy in the video created Console Application based on .Net Framework. What you created is .Net 5 which is base on .net core technology.

I encourage you to study about what is different about them. But for now you should know your NumberGuesser.exe file needs the NumberGuesser.dll to be next to it. unless you publish your project as self contained.

MrMoeinM
  • 2,080
  • 1
  • 11
  • 16
  • *** Self-contained publishing works when I use the .NET Core 3.1 framework instead of .NET 5.0. I'm just lacking in knowledge. Thanks! – dbm94 Jun 29 '21 at 08:31
  • Does the guy in the video simply not have to even publish his file because he's using the .NET Framework? Or is it likely that he published it before creating the video? – dbm94 Jun 29 '21 at 08:35
  • No he needs to publish it. What you see is simply a debug version of application with no optimization and lot's of debug info. You publish when you need to release your application not for every test and run in your local computer. – MrMoeinM Jun 29 '21 at 08:59