This is such thing as the location of a main executable module of the entry assembly:
string exePath = System.Reflection.Assembly.GetEntryAssembly().Location;
Of course, you can get the location of any given assembly, such as the calling one. Strictly speaking, an assembly does not have to be a single file and may be implemented in different modules, but Visual Studio supports creation of only single-module assemblies (the referenced assemblies are not counted, they are different assemblies). In all cases, the assembly location is the location of its main executable module. Please see:
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx[
^].
There are a number of other methods, but some of them require additional references, and some gives different results depending on how the application is hosted; this method is the reliable one.
—SA