Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NETApp.config
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?
Posted 14-Nov-12 8:17am
Comments
Christian Graus at 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.
Zombie Code Monkey at 15-Nov-12 10:28am
   
I was starting to lean that direction anyway. Thanks for confirming it.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,448
1 Tadit Dash 270
2 OriginalGriff 223
3 Sergey Alexandrovich Kryukov 215
4 Peter Leow 180
0 Sergey Alexandrovich Kryukov 9,440
1 OriginalGriff 5,618
2 Peter Leow 4,280
3 Maciej Los 3,540
4 Abhinav S 3,363


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid