简体   繁体   中英

How to update both 32 & 64 bit machine.config

Our solution is a suite of windows and web services that can all run on one machine or be fully distributed.

We need only one piece of config to tie all of these together (it happens to be a RabbitMq endpoint but that's not important).

Some of our services need to run as 32bit apps, some of the web services will run in 32 bit app pools, so we have a mix of processes running as 64 and 32 bit, often on the same machine.

By preference we'd put our one piece of config into the .net machine.config. My current task is to write a bare bones win-forms UI to update the machine.config with our piece of config.

However, by default, opening the machine config with

config = System.Configuration.ConfigurationManager.OpenMachineConfiguration();

Opens the machine.config associated with the bit-edness of the running UI, however I need to update both 32 & 64 bit machine config files with the same value .

Is there a known - and safe - method to do this?

My first instinct is to have a console app that the UI can call out to do the actual update, and have 2 different flavors one 32 and one 64 bit.

Or is there a better way to do this?

I think you should be able to use the OpenMappedMachineConfiguration method on the ConfigurationManager to open a specific machine config file.

var path = "path to desired machine config";
ConfigurationFileMap cfm = new ConfigurationFileMap(path);
Configuration config = ConfigurationManager.OpenMappedMachineConfiguration(cfm);

More information on the method can be found here: http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.openmappedmachineconfiguration(v=vs.110).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM