Click here to Skip to main content
15,846,342 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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?
Christian Graus 14-Nov-12 14:20pm    
I've had the same issue and found no work around, found I had to set up config in the exe.config, not in the config for dlls we use.
[no name] 15-Nov-12 10:28am    
I was starting to lean that direction anyway.

Thanks for confirming it.

1 solution

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
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900