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

How to obtain app.config of a different application and modify it

375 256MB
Hi,

I have two windows application. eg ., FormA and FormB

The app.config of FormA is as below

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <configuration>
  3.   <appSettings>
  4.     <add key="company" value="DSRC"/>
  5.     </appSettings>
  6. <connectionStrings>
  7. <add name="test" connectionString="Testing Connection String"/>
  8. </connectionStrings>
  9. </configuration>
  10.  
Now I have another application named as Form B.

I want to retrieve both appsettings and connectionstrings of Form A into Form B.

Further I should be able to modify both of these appsettings and connection strings and save it into the Form A.

I know how to retrieve the appsettings , and connection strings of the same application and modify.

But how do I obtain of some other application and modify the same.

Kindly do let me know.


Regards

cmrhema
Feb 15 '10 #1

✓ answered by cmrhema

The post has been resolved.
I looked here...
http://social.msdn.microsoft.com/For...3-da231a701384

4 2095
tlhintoq
3,525 Expert 2GB
You are referring to different forms, but calling them different applications so I'm not sure if you really mean two different applications or two forms in one application.

If you mean two forms in one application...
Why does your form A need to know anything about the details of your form B?

That doesn't really follow the basic tennant of OOP where each object is responsible for itself and nobody else. At most FormA should instruct FormB to load it's settings.

Expand|Select|Wrap|Line Numbers
  1. FormB.LoadSettings();
But FormA shouldn't do it on behalf of FormB.

If FormA has to know a specific value from FromB, then put a public property in FormB that FormA can reach.

If you mean some shared data in two different applications...
Personally I would just put the shared data in the registry so both applications can reach it.
Feb 15 '10 #2
cmrhema
375 256MB
Actually I have 4 windows services running under one setup., one webservice and one wcf service and one application.
All these have different app.configs, comprising of different appsettings and different connection strings.
I am supposed to create a windows application that will retrieve each of these settings and then save it accordingly.

I tried upto this level
Expand|Select|Wrap|Line Numbers
  1. ExeConfigurationFileMap filename= new ExeConfigurationFileMap();
  2. fileMap.ExeConfigFilename = @"D:\Home\FormA\FormA\bin\Debug\FormA.exe";
  3.  
  4.  
  5. Configuration config =
  6.    ConfigurationManager.OpenMappedExeConfiguration(filename,
  7.    ConfigurationUserLevel.None);
But then just got struck, I just do not know how to proceed futher (Sounds dumb right !).

I am able to retrieve all the keys related to appsettings but not the connectionstrings.

And to the reply to your question as why should we be retrieving appsettings is,
We are going to send this to our client, who will decide the database, In other words database will be changed, further we have set a time for the sockets to recieve data, the polling time, the interval everything under the appsettings and connectionstrings.
The client wants to modify these, hence the need for controlling appsettings for the whole package arises.
Please do not suggest to add ConfigurationSettings into the appsettings, as my request has been turned down by my TL
Feb 16 '10 #3
cmrhema
375 256MB
The post has been resolved.
I looked here...
http://social.msdn.microsoft.com/For...3-da231a701384
Feb 16 '10 #4
tlhintoq
3,525 Expert 2GB
Google and MSDN to the rescue! Hurray! Hazaa hazaa. The crowd goes wild.

Happy to see you have this resolved.
Feb 16 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Fuzzyman | last post by:
There have been a couple of config file 'systems' announced recently, that focus on building more powerful and complex configuration files. ConfigObj is a module to enable you to much more *simply*...
3
by: david | last post by:
I found my web.config file always in lock mode, when I tried to modify it, I ofter got "Can not create web.config" error. I had to reboot my machine, and before I accessed any site I can modify it....
5
by: AAguiar | last post by:
I have an asp.net project where the code behind the aspx page calls a c# class which makes calls to a managed static C++ class. The C# class works fine when the asp net worker process starts, when...
3
by: Christopher Kimbell | last post by:
I have a class library that contains a number of TableAdapters and I'm using this from a web application. Is there a way of getting the TableAdapters to use the connectionstrings defined in...
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...
3
by: Bob | last post by:
Over the life of a distributed app, it is possible for the connection string that it was configured with initailly needs to change. You can't scope a connection string setting to user so that it...
1
by: DC | last post by:
Hi, before I start to program a tool from scratch I wanted to check if somebody knows an existing solution: we often have the demand to modify a certain config value in many .config (web.config...
3
by: Jeff | last post by:
I have a solution with two projects. Project A is the startup project, while Project B serves as the project with the data logic. At run time, the first thing I need to do is write to Project...
4
by: Raymon Du | last post by:
Hi, I am getting the following exception every time I modified web.config, the only way to fix it is to recycle application pool or restart IIS, but I don't want to do that all the times. TIA
2
by: Johnson | last post by:
I'm trying to fix a "sub optimal" situation with respect to connection string management. Your thoughtful responses will be appreciated. I just started with a new client who has a bunch of legacy...
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
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: 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...
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
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...
0
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...

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.