473,796 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ConfigurationSe ttings.GetConfi g

[STAThread()]
public static void Main()
{
string sectionName = "system.web ";
object settings = ConfigurationSe ttings.GetConfi g(sectionName);
Console.WriteLi ne(
settings == null ? "(null)"
: settings.GetTyp e().ToString()
);
}

I'm trying to access the system.web section in the machine.config file. I
thought that ConfigurationSe ttings.GetConfi g would get the configuration
section that match the sectionName above, from all loaded configuration
files. When I run this, it always gives me null. So, how can I get the
"system.web " section of the machine.config file using ConfigurationSe ttings?
If I can't do it this way, and I have to do it by loading the machine.config
as an XmlDocument, then what is the best way to get the path to the
machine.config file? I know there are registry keys and I could use
Path.Combine to combine paths, but is there a property on an object that
gives at least part of the path information to the machine.config file?

Any help is appreciated :)

Thanks,
Mythran

Nov 17 '05 #1
2 6409
I can tell you why it doesn’t work... but not how to get around it just yet.

ConfigurationSe ttings.GetConfi g() is defined as: “Returns configuration
settings for a user-defined configuration section.” and system.web is not a
user defined configuration setting.

Give me a few on trying to find machine.config.

Brendan
"Mythran" wrote:
[STAThread()]
public static void Main()
{
string sectionName = "system.web ";
object settings = ConfigurationSe ttings.GetConfi g(sectionName);
Console.WriteLi ne(
settings == null ? "(null)"
: settings.GetTyp e().ToString()
);
}

I'm trying to access the system.web section in the machine.config file. I
thought that ConfigurationSe ttings.GetConfi g would get the configuration
section that match the sectionName above, from all loaded configuration
files. When I run this, it always gives me null. So, how can I get the
"system.web " section of the machine.config file using ConfigurationSe ttings?
If I can't do it this way, and I have to do it by loading the machine.config
as an XmlDocument, then what is the best way to get the path to the
machine.config file? I know there are registry keys and I could use
Path.Combine to combine paths, but is there a property on an object that
gives at least part of the path information to the machine.config file?

Any help is appreciated :)

Thanks,
Mythran

Nov 17 '05 #2

"Brendan Grant" <gr****@NOSPAMd ahat.com> wrote in message
news:6C******** *************** ***********@mic rosoft.com...
I can tell you why it doesn’t work... but not how to get around it just
yet.

ConfigurationSe ttings.GetConfi g() is defined as: “Returns configuration
settings for a user-defined configuration section.” and system.web is not
a
user defined configuration setting.

Give me a few on trying to find machine.config.

Brendan


How about 3½ hours? :P I know I can get it from the registry, so don't
destroy a brain cell trying to figure out other ways if you don't "need" to
:)

Thanks in any case ;)

Mythran

Nov 17 '05 #3

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

Similar topics

0
2504
by: Michael | last post by:
Scenario: I have a .Net Class Solution, I am using a windows test application to call the class for testing purposes. When I add an app.config file to the class solution it does not add it to the bin directory, but when I add it to the test application it does add it to the bin directory. Needless to say the problem I have is that when I use the (ConfigurationSettings.GetConfig('ConfigSection'), UIPConfigSettings)
3
2134
by: serge calderara | last post by:
Dear all, I have define a configuration file for my application with different section groups and settings belonging to each individual group like as follow : ===================================================== <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections>
0
1238
by: Keith Patrick | last post by:
If I call ConfigurationSettings.GetConfig(...) the first time, it works fine, demanding no permissions. However, if I call it again for a different section, it demands FileIOPermission Read/PathDiscovery permission to the app's directory (kind of difficult to assign this permission to the assembly in this case). Is this a bug or intended behavior? I don't really see why a second call would be any different from the first, unless there is...
3
3134
by: Filippo | last post by:
Hi there, I am writing a Windows App and need a Configuration file. I wonder if I can use the WEB.CONFIG file to store my values. I also wonder if I can use the ConfigurationSettings.AppSettings and if so, what is the file name that it automatically look for. Thanks, Filippo
9
5080
by: james | last post by:
According to the documentation ConfigurationSetting.GetConfig( string ) is used to get user defined config settings. Yet, no matter how I try to add my own sections to the app.config I keep getting errors stating an invalid config file section found. So, can someone elighten me as to how this is to be used ?? thanks JIM
2
1300
by: J Holsinger | last post by:
In VB.Net solution I have Standard Windows app and a Web app that references a Class library. Both the Win app and the class library use the same technique in the code files for retrieving identical custom config sections in their respective app.config's. The win app runs without error, the class library being used in the web app can't parse it's own app.config. Does anybody know what would cause behavior like that? -- thx -jsh
0
1302
by: Steph | last post by:
hello, in .NET1 i used this command for read a specific xml file config: ConfigurationSettings.GetConfig how to make in .NET 2 ? keep in mind : i need to read a specific file not the wep.config or other .dotnet config file.. thx mau
2
6465
by: Glenn | last post by:
Hi Anyone know the equivalent to NameValueCollection nvc = ConfigurationSettings.GetConfig( "SectionGroup/Section" ) as NameValueCollection; in .Net 2.0. All the examples I've seen involve creating a customer handler.
8
2651
by: Mark | last post by:
Could someone provide me with details or a link on how the line of code executes underneath the hood? Assume it's executed in an ASP.NET application. string blah = ConfigurationSettings.AppSettings Once your application has called for the "foo" key once, how expensive is to call the same line again? My gut tells me that the CLR likely stores these values in memory in a string dictionary or similar. Looking up the value requires the...
0
9525
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
10452
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10221
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
10169
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
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5440
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
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.