简体   繁体   English

如何更新32和64位machine.config

[英]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. 我们的解决方案是一套Windows和Web服务,可以在一台机器上运行或完全分布。

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). 我们只需要一个配置来将所有这些绑定在一起(它恰好是RabbitMq端点,但这并不重要)。

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. 我们的一些服务需要作为32位应用程序运行,一些Web服务将在32位应用程序池中运行,因此我们混合使用64位和32位运行的进程,通常在同一台机器上运行。

By preference we'd put our one piece of config into the .net machine.config. 我们首先将我们的一个配置放入.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. 我目前的任务是编写一个简单的win-forms UI来使用我们的配置更新machine.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 . 打开与正在运行的UI的位编辑相关联的machine.config,但是我需要更新具有相同值的32位和64位计算机配置文件

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. 我的第一直觉是拥有一个控制台应用程序,UI可以调出来进行实际更新,并有两种不同的风格,一个32位和一个64位。

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. 我认为你应该能够在ConfigurationManager上使用OpenMappedMachineConfiguration方法来打开特定的机器配置文件。

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 有关该方法的更多信息,请访问: http//msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.openmappedmachineconfiguration(v=vs.110).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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