引用的dll引用的App.config值 [英] App.config values referenced by a referenced dll

查看:101
本文介绍了引用的dll引用的App.config值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是交易。我花了最近几天在互联网上寻找解决这个问题的方法并且基本放弃了。我们有一个菜单应用程序加载其他编译为dll的应用程序使用

Here''s the deal. I''ve spent the last several days digging through the Internet looking for a solution to this problem and have basically given up. We have a menu application that loads other apps compiled as dlls using

Assembly myDLL = Assembly.LoadFrom(baseURL + dbDllName + baseDLLextension);



这不是问题本身。我们有很多以这种方式加载的堆,当他们需要引用自己的app.config时,一切都按预期工作。问题是我最近不得不修改其中一个引用dll的菜单应用程序,这些dll引用了其他几个dll,其中大多数使用配置文件。



我''已经包含了我的app.config文件中所有其他dll需要的所有必要值。当我将我的应用程序作为独立的exe或IDE运行时,它运行正常。从菜单应用程序加载我的应用程序时会出现问题。



似乎.Net期望只读取执行程序app.config。我尝试使用以下代码,但是当我的应用程序从菜单加载时失败。


This is not the problem in and of itself. We have many aaps that are loaded this way and when they need to reference thier own app.config, everything works as intended. The problem is I recently had to modify one of these menu apps that references a dll that reference several other dlls, most of which use a configuration file.

I''ve already included all the necessary values in my app.config file that all the other dlls need. And it runs fine when I run my app as a standalone exe or from the IDE. The problem occurs when my app is loaded from the menu application.

It seems that .Net expects to only read from the execuatbles app.config. I''ve attempted using the following code, but this fails when my app is loaded from the menu.

System.Configuration.ExeConfigurationFileMap configFileMap = new System.Configuration.ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = @"\\NetworkPath\Folders\My.dll.config";
System.Configuration.Configuration config =
    System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(configFileMap, System.Configuration.ConfigurationUserLevel.None);



允许我读取引用的dll所需的值,但它不允许dll读取值。



我的最后一次尝试是手动加载所有引用的dll都使用Assembly.LoadFrom(),但是它给出了与我所有其他尝试相同的结果。我们正在努力做甚么可能吗?有没有其他人遇到这个senario?


This does allow me to read the values necessary for the referenced dlls, but it isn''t allowing the dlls to read the values.

My last attempt was to manually load all the referenced dlls using Assembly.LoadFrom(), but that gave the same results as all my other attempts. Is what we''re trying to do even possible? Has anyone else run into this senario?

推荐答案

不幸的是这是它的工作原理,你需要在你的主app.config中拥有所有必需的值作为dll'被认为是正在运行的应用程序的一部分
Unfortunately this is the was it works, you need to have all required values in your main app.config as the dll''s are considered part of the running application


这篇关于引用的dll引用的App.config值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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