Sharing Config File Between Processes

  • Thread starter Thread starter Jim Davis
  • Start date Start date
J

Jim Davis

Is there any way to specify the location of the config file that I want the
app to use? I have multiple processes that work together and share most of
their configuration data. I only want to store it in one location. I have
looked at the Configuration App Block, and that is both too complex and too
limiting for our needs.
 
Hi Jim,

no it is not. The configuration file standards to
assemblyname.extension.config (such as myapp.exe.config). If you require to
share configurations you can define a link to a standard xml configuration
file which you'll have to process manually. For example you can add the link
to the appSettings section:

<appSettings>
<add key="myconfig" value="mysharedconfig.xml"/>
</appSetting>

Then you can define your shared settings in the mysharedconfig.xml and
implement a reader on the xml file.

That's how I do it and AFAIK there's no other way to do so.

Regards,
Michael
 
Thanks. It sure seems like a simple thing to support. I wonder why MS does
not allow pointing to any file we choose.
 
Hi Jim,
Thanks. It sure seems like a simple thing to support. I wonder why MS
does not allow pointing to any file we choose.

This is because of the AppDomain model of the .Net Framework. Since .Net
applications can contain their own assemblies, the AppDomain is specific to
a set of folders and sub-folders. Configuration data can be contained in
config files in the application folders, or it can be shared via the
configuration files on the System, such as machine.config. In fact, you can
always use these "global" configuration files for shared configuration
settings, which is what they are designed for.

Once you step outside of this model, you must construct your own.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.
 
You can share application settings using the file attribute of the
appSettings tag in your config file.

App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings file="c:\general.settings.config"></appSettings>
</configuration>

general.settings.config

<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="SomeKey" value="SomeValue"/>
</appSettings>


Best regards,
Paul Gielens

Visit my blog @ http://weblogs.asp.net/pgielens/
###
 
Great to know, I was not aware of that...

Paul Gielens said:
You can share application settings using the file attribute of the
appSettings tag in your config file.

App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings file="c:\general.settings.config"></appSettings>
</configuration>

general.settings.config

<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="SomeKey" value="SomeValue"/>
</appSettings>


Best regards,
Paul Gielens

Visit my blog @ http://weblogs.asp.net/pgielens/
###
 
Back
Top