Click here to Skip to main content
12,505,104 members (60,494 online)

App.config values referenced by a referenced dll

Zombie Code Monkey asked:

Open original thread
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);
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);
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?
Tags: .NET, App.config

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100