最近项目想做到每个dll读取自己的配置文件进行一些数据处理,具体方法如下:
string temp = string.Empty; //接收
var path = System.Reflection.Assembly.GetExecutingAssembly().Location.ToString();
try
{
System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(path);
temp = config.ConnectionStrings.ConnectionStrings[key].ConnectionString;//取值
}
catch (Exception)
{
}