Why does System.Reflection.Assembly.GetEntryAssembly().Location returns .dll instead of .exe? #61000
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Beta Was this translation helpful? Give feedback.
-
The .NET Framework's You can publish your application as a so called "single-file", which will produce a single executable (in .NET 6 it is truly a single file): https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file As for the APIs - Please note that with "single-file" publish the managed assembly is just a piece of data embedded in the If you're just looking for the directory in which the app is, the recommended API for that is |
Beta Was this translation helpful? Give feedback.
The
.dll
is a managed assembly (same format as with .NET Framework), it's an intermediate language code, not directly executable by the OS. The.exe
is a small shim, which knows how to find the .NET runtime, loads it, and tells it to run the code in the.dll
. The.exe
is a directly executable code..NET Framework's
.exe
was also a managed assembly with no directly executable code, but since .NET Framework is part of the OS, the OS knows that these are "managed executables" and handles the "shim" part in the OS loader directly (find the runtime, load it, ask it to execute the managed code). Starting with .NET Core (and later on with .NET) this approach was abandoned, as it can really only …