获得从引用的DLL在C#中执行的程序集名称名称、程序、DLL

由网友(Gloaming°薄暮城)分享简介:什么是从引用的类库得到执行的程序集的应用程序名称(即MyApplication.exe)在C#中的最佳方法是什么?What is the best way to get the application name (i.e MyApplication.exe) of the executing assembly fro...

什么是从引用的类库得到执行的程序集的应用程序名称(即MyApplication.exe)在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#?

我需要打开应用程序的app.config中检索某些的appSettings为引用的DLL的变量。

I need to open the application's app.config to retrieve some appSettings variables for the referenced DLL.

推荐答案

如果你想获得当前应用程序域的配置文件,那么所有你需要做的是:

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

ConfigurationManager.AppSettings ...

(这需要一个参考当然要S​​ystem.Configuration)。

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

要回答你的问题,你可以做到这一点为雷说(或使用 Assembly.GetExecutingAssembly()。全​​名),但我认为这个问题是比较容易解决的使用 ConfigurationManager中

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.

阅读全文

相关推荐

最新文章