What is the best way to get the application name (i.e MyApplication.exe) of the executing assembly from a referenced class library in C#?
I need to open the application's app.config to retrieve some appSettings variables for the referenced DLL.
To get the answer to the question title:
// Full-name, e.g. MyApplication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null string exeAssembly = Assembly.GetEntryAssembly().FullName; // or just the "assembly name" part (e.g. "MyApplication") string exeAssemblyName = Assembly.GetEntryAssembly().GetName().Name;
As mentioned by @Ben, since you mention wanting to get the configuration information, use the ConfigurationManager
class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With