473,386 Members | 1,812 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,386 software developers and data experts.

App.config question. Me is stuck good :-(

Hi everyone,

I really need help with the following:

It's common in app development to create numerous projects under one
solution that as a whole combine to become your final application. For
example I have a solution that has four subprojects - 3 class libraries and
1 windows forms app.

Q - Some of these projects - both class library and win form application
require access to a config file. In one of the projects - the one that
supports data access I use the line below to access a custom config section:

ChaosDataConfiguration config =
(ChaosDataConfiguration)ConfigurationSettings.GetC onfig("TheChaosLibraries/DataProviderSettings");

The problem I'm having is I don't know if this is going to work. Should the
App.config file be placed under the data projects directory, or is there
some way to create a single config file at the root of the solution and have
all projects access that?

Any help would be greatfully received.

Thanks all
I do not think that one config file can be used by more then one
application. Remember, the config file has to be named the same as
program
for it to load.

"Simon" <sh856531@microsofts_free_email_service.com> wrote in message
news:uK*************@TK2MSFTNGP09.phx.gbl...
Hi all,

When you make a solution that contains numerous projects - where should

you
put the configuration file that should be used for the application?

Example:

An application called MyApp has 4 projects each contained within their
own
subdirectories. Each project outputs its dll to its own bin directory.

The folder structure is:

MyApp
- MyProject 1
- MyProject 2
- MyProject 3
- MyProject 4

Where should I put the config file so that all the projects access it?

Is it even possible to have a single config file shared amongst multiple
projects? I'm sure it is - I just can't find any details on how to do it.

If anyone has any advice on this I would appreciate it very much

Thanks in advance everyone

Simon


Jul 21 '05 #1
3 1787
Hi,

Create a file named app.config (yes, this is the exact name) under the
start-up project (the Winforms app in your case). When you run this project,
all the class libraries get copied to the project's 'bin' directory, as well
as the app.config file is renamed to "yourapp.exe.config" and also copied to
the 'bin' folder. Thus, you get a single config file!

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Simon" <sh856531@microsofts_free_email_service.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi everyone,

I really need help with the following:

It's common in app development to create numerous projects under one
solution that as a whole combine to become your final application. For
example I have a solution that has four subprojects - 3 class libraries
and 1 windows forms app.

Q - Some of these projects - both class library and win form application
require access to a config file. In one of the projects - the one that
supports data access I use the line below to access a custom config
section:

ChaosDataConfiguration config =
(ChaosDataConfiguration)ConfigurationSettings.GetC onfig("TheChaosLibraries/DataProviderSettings");

The problem I'm having is I don't know if this is going to work. Should
the App.config file be placed under the data projects directory, or is
there some way to create a single config file at the root of the solution
and have all projects access that?

Any help would be greatfully received.

Thanks all
I do not think that one config file can be used by more then one
application. Remember, the config file has to be named the same as
program
for it to load.

"Simon" <sh856531@microsofts_free_email_service.com> wrote in message
news:uK*************@TK2MSFTNGP09.phx.gbl...
Hi all,

When you make a solution that contains numerous projects - where should

you
put the configuration file that should be used for the application?

Example:

An application called MyApp has 4 projects each contained within their
own
subdirectories. Each project outputs its dll to its own bin directory.

The folder structure is:

MyApp
- MyProject 1
- MyProject 2
- MyProject 3
- MyProject 4

Where should I put the config file so that all the projects access it?

Is it even possible to have a single config file shared amongst multiple
projects? I'm sure it is - I just can't find any details on how to do
it.

If anyone has any advice on this I would appreciate it very much

Thanks in advance everyone

Simon




Jul 21 '05 #2
Hi,

Let me first get your problem correctly... You have a 4 projects, 1 which is
Windows Forms App and the other three class librarires. I assume it is going
to be DLL (basically in-process).

So in that case, you just have to have your application configuration in the
Windows Forms Application which will have the process of its own and all the
class libraries will be loaded into this process. The class libraries will
use the configuration file of the surrogate process which in this case is
the Windows forms App. You can just use the following code segment to access
the appsettings.

ConfigurationSettings.AppSettings[<appsettings-element>]

I guess this way you don't have to worry about multiple configuration files.

Hope this helps...

Regards,
Madhu

MCSD.NET | C# - MVP

"Simon" <sh856531@microsofts_free_email_service.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi everyone,

I really need help with the following:

It's common in app development to create numerous projects under one
solution that as a whole combine to become your final application. For
example I have a solution that has four subprojects - 3 class libraries
and 1 windows forms app.

Q - Some of these projects - both class library and win form application
require access to a config file. In one of the projects - the one that
supports data access I use the line below to access a custom config
section:

ChaosDataConfiguration config =
(ChaosDataConfiguration)ConfigurationSettings.GetC onfig("TheChaosLibraries/DataProviderSettings");

The problem I'm having is I don't know if this is going to work. Should
the App.config file be placed under the data projects directory, or is
there some way to create a single config file at the root of the solution
and have all projects access that?

Any help would be greatfully received.

Thanks all
I do not think that one config file can be used by more then one
application. Remember, the config file has to be named the same as
program
for it to load.

"Simon" <sh856531@microsofts_free_email_service.com> wrote in message
news:uK*************@TK2MSFTNGP09.phx.gbl...
Hi all,

When you make a solution that contains numerous projects - where should

you
put the configuration file that should be used for the application?

Example:

An application called MyApp has 4 projects each contained within their
own
subdirectories. Each project outputs its dll to its own bin directory.

The folder structure is:

MyApp
- MyProject 1
- MyProject 2
- MyProject 3
- MyProject 4

Where should I put the config file so that all the projects access it?

Is it even possible to have a single config file shared amongst multiple
projects? I'm sure it is - I just can't find any details on how to do
it.

If anyone has any advice on this I would appreciate it very much

Thanks in advance everyone

Simon



Jul 21 '05 #3
Thats perfect guys. I'll give that a shot.

Thank you very much for your help

Kindest Regards

Simon
Jul 21 '05 #4

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

Similar topics

33
by: John Timbers | last post by:
I'd like to purchase Visual C# .Net for learning purposes only since it's a lot cheaper than Visual Studio (note that I'm a very experienced C++ developer). Can someone simply clarify the basic...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
3
by: Simon | last post by:
Hi everyone, I really need help with the following: It's common in app development to create numerous projects under one solution that as a whole combine to become your final application. For...
5
by: BPearson | last post by:
Hello I would like to have several sites share a single web.config file. To accomplish this, I would point the root of these sites to the same folder. Is there any reason why I might not want to...
16
by: Timm | last post by:
I'm trying to use ASP objects (basically formed and populated based on Web.Config settings) and I want to use them in a different non-asp program with minimal reprogramming. So, my question is how...
5
by: Dean Slindee | last post by:
I store several application settings in the project's "app.config" file. I also have a form that reads these values and displays them in a listview so that the user can adjust them. My question...
12
by: shawnn | last post by:
Hello, By default, when you create an App.config file it gets named as MyApp.exe.config after build. I don't like this name and would rather have the file named MyApp.config, the .exe.config...
20
by: tomerfiliba | last post by:
hey i've been seeing lots of config-file-readers for python. be it ConfigObj (http://www.voidspace.org.uk/python/configobj.html) or the like. seems like a trend to me. i came to this conclusion...
11
by: TARUN | last post by:
Hello All I need to ask about the configuration file in .NET, There are Two config File 1. Web Config 2. Machine config I understand the the usage of Web config , but not able to understand...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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?
0
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...
0
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,...
0
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...

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.