473,378 Members | 1,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

system.configuration net 2.0 - save

Hello,

I am having troubles saving configuration file.

I did the folloing: inherited from ConfigurationSection,
ConfigurationCollection, ConfigurationElement to define my own element in
config file.

If I do the following:

using System.Configuration;

System.Configuration.Configuration configFile;
this.configFile =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None);
DatabaseConnectionSection dcs;
dcs = new DatabaseConnectionSection();
DatabaseConnectionSettings cn = new DatabaseConnectionSettings();
cn.Name = "connectionName";
dcs.Connections.Add(cn);
this.configFile.Sections.Add(DatabaseConnectionSec tion.Name, dcs);
this.configFile.Save(ConfigurationSaveMode.Full);

everything works fine, I can save and load the settings on the next run.

Hoever I'd like to store the section in separate file.
So after dcs instantiation I did:
dcs.SectionInformation.ConfigSource = "DatabaseConnections.config";

on execution of the last line in above I get an exception "Object reference
not set to an instance of an object."
the config file has this file added:
<DatabaseConnections configSource="DatabaseConnections.config" />

But the file itself isn't created and the application can't start on the
next run because of this.

I think, the problem is in the filePath or there is something else I need to
set in SectionInformation, but the docs aren't clear about that

CUIN Kaczy
Nov 17 '05 #1
0 2500

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

Similar topics

1
by: Supra | last post by:
i got "system error" when saving to xml file. i am using checkbox1 control to xml. when user clicked checkbox and set to true and press btnOk to conform and save it to xml ...
0
by: Supra | last post by:
i got "system error" when saving to xml file. i am using checkbox1 control to xml. when user clicked checkbox and set to true and press btnOk to conform and save it to xml ...
0
by: cyberstrike | last post by:
In the system.configuration namespace, is there any way to save a Dataset or any other custom structure in a section? I know how to make a class and derive it from the section class; however, any...
0
by: SR | last post by:
I am trying to use the Configuration object provided with the .NET 2.0 framework. I see that when I call the Save function it does update the <application>.exe.config file. However, when I close...
1
by: Sky | last post by:
Yesterday I was told that GetType(string) should not just be with a Type, but be Type, AssemblyName. Fair enough, get the reason. (Finally!). As long as it doesn't cause tech support problems...
1
by: Shannon Richards | last post by:
Hello All: I have implemented a custom configuration section in my app.config file as follows: <configSections> <section name="AdminUIConfig" type="TestMgr.UIConfigSection,TestMgr"/>...
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
0
by: Shaikh shahnawaz | last post by:
Hi, I have implement multiple file uploading progress bar with the help of flash and .net file is upload on my local machine but not working with server it's give error while uploading image on...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi misters, I have an app.config (UTF-8 format file). I create an application winforms for changes and save configuration programatically. When I save changes the format file changes to ANSI ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.