473,804 Members | 3,182 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

loading other-than-default app.config files

j
I'm trying to write a section of code so that several applications
that all share some configuration options can load those options from
a single .config file. This code compiles and executes w/o error, but
it will not return the contents of any config file I give it.
The code to dump the sections always reports sections that do not
exist in the file.
Looking at appConfig.Type, the public key does not match the one in
the file.
What am i doing wrong?

FileInfo fi = new
FileInfo(Assemb ly.GetExecuting Assembly().Loca tion);

ExeConfiguratio nFileMap fileMap = new
ExeConfiguratio nFileMap();
string configfile =
Path.Combine(fi .DirectoryName, @"global.config ");
// string configfile = @"global.config ";
fileMap.ExeConf igFilename = configfile; // relative path
names possible

// Open another config file
Configuration config =

ConfigurationMa nager.OpenMappe dExeConfigurati on(fileMap,
ConfigurationUs erLevel.None);
ConfigurationSe ction appConfig = config.AppSetti ngs;

Console.WriteLi ne();
Console.WriteLi ne("Sections in "+config.FilePa th);

// Loop to get the sections machine.config.
foreach (ConfigurationS ection section in sections)
{
string name = section.Section Information.Nam e;
Console.WriteLi ne("Name: {0}", name);

Console.WriteLi ne(section.Sect ionInformation. GetRawXml());
}
..config file===========
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<configSections >
<sectionGroup name="applicati onSettings"
type="System.Co nfiguration.App licationSetting sGroup, System,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9" >
<section name="Utilities .Global"
type="System.Co nfiguration.Cli entSettingsSect ion, System,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
requirePermissi on="false" />
</sectionGroup>
</configSections>
<applicationSet tings>
<Utilities.Glob al>
<setting name="User" serializeAs="St ring">
<value>scott</value>
</setting>
<setting name="Password" serializeAs="St ring">
<value>tiger</value>
</setting>
<setting name="Source" serializeAs="St ring">
<value>oraHom e</value>
</setting>
</Utilities.Globa l>
</applicationSett ings>
</configuration>

Apr 6 '07 #1
0 2909

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
21317
by: BKM | last post by:
I've been using the following 2 ways to make sure my WebBrowser is finished loading a page before continuing with the next code. do:doevents:loop while WebBrowser.Busy do:doevents:loop until WebBrowser.ReadyState = STATE_COMPLETE (or something like that. I don't have the code in front of me) But, for some reason, occasionally the code continues past the loops even
2
3145
by: Foehammer | last post by:
Hello, I'm trying to load an assembly dynamically using an app domain. This is a proof-of-concept for a larger project, so please excuse the lame class names. TestLib is the dll where all the dynamic loading code will go. The assemblies being dynamically loaded do not contain any code. They are resource-only assemblies. I have succeeded in dynamically loading them within the same AppDomain as the main application (a Winforms EXE that...
6
3125
by: Curious George | last post by:
I have a page that takes about 10 seconds to load the first time it is run. I would like to first display a little animated gif telling the user that the page is loading. How do I do this with .NET? I used to create a loading layer at the top of the page. Flush the layer to the buffer.
1
1557
by: Angel | last post by:
Is there a way to display a message using an aspx page with controls on it that the data is loading for the page without having to display one html page then reloading the aspx page. in other words display a message on the aspx page before all the controls are loaded and the data, then display the controls with the data all in one aspx page? or if there is another way to do this, please how... thanks
0
1319
by: Joe | last post by:
I've a web form that inherits from a BasePage. There is a user control on the web form. Does anyone thinks it's a problem if I've my BasePage loading a user control and my web form loading a different user control. I'm more worry on the sequence as which user control gets loaded first. The user control I've on the web form depends on the user control on the BasePage to load first. Most of the time, it seems everything is ok (BasePage...
2
1895
by: hbchai | last post by:
I'm adapting the ajax-like asynchronous request pattern mentioned in this article: http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html?page=2 for my Sudoku implementation: http://ttwhy.org/code/mosudoku.html By changing the "src" attribute of a script tag, I can dynamically load
6
1694
by: Pieter | last post by:
Hi, I developed an Outlook Add In (VB.NET 2005, for Outlook 2003) that sometimes suddenly stops loading. I've put everywhere in the code Exception Handlers, but no Exception is catched. it seems that other add ins aren't loaded afterwarths (nod32). Does anybody know a way to find out why an outlook add could do this? and find out after the problem what caused the problem?
5
10369
by: toffee | last post by:
Hi all, I've seen a really cool effect which i would like to use on an intranet site. Am referring to the 'LOADING..' animation you see when switching pages. I've seen it somewhere on a website that was using php (cant remember the url). I've tried googling but came up with nothing - so does anyone know what function of php allows to display a little animation while a sql query is being run ? Many thanks
2
3216
by: boczek | last post by:
Hello all. I'm writing a small async webapp. in JavaScript and I'm using <script> element technique to load data. I'm usign <scriptbecause of cross domain restrictions with XmlRequest. The problem is when I remove a element that is currently loading from DOM (with removeChild) Firefox still loads it and waits with other scripts.
20
4306
by: Nickolai Leschov | last post by:
Hello all, I am programming an embedded controller that has a 'C' library for using its system functions (I/O, timers, all the specific devices). The supplied library has .LIB and .H files. How can I dynamically load a LIB file and access all its functions? Surely someone has solved similar task? My intention is to use a Forth system for programming the controller,
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9577
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10315
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.