Sunday, September 30, 2018

.net - Get executing assembly name from referenced DLL in C#



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.



Answer



If you want to get the current appdomain's config file, then all you need to do is:



ConfigurationManager.AppSettings....



(this requires a reference to System.Configuration of course).



To answer your question, you can do it as Ray said (or use Assembly.GetExecutingAssembly().FullName) but I think the problem is easier solved using ConfigurationManager.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...