获得从引用的DLL在C#中执行的程序集名称 [英] Get executing assembly name from referenced DLL in C#

查看:389
本文介绍了获得从引用的DLL在C#中执行的程序集名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这篇关于获得从引用的DLL在C#中执行的程序集名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆