Как отредактировать machine.config

Разработка на C# под linux
 

Возможные поисковые запросы

how to modify machine.config programmatically
How to modify machine.config file with a C# class?

Результаты поиска

http://stackoverflow.com/questions/34824445/how-to-create-a-modified-copy-of-machine-config-file
https://forums.iis.net/t/1164506.aspx

Ключевые слова и варианты решений

Plain XML manipulations

write a simple console application which does not use any data provider and parse and fix the configuration file through plain XML manipulation.

the error is not raised by your application, it's raised by the .NET framework which fails to validate the machine.config when it reads it.
Because the validation fails and the configuration is not loaded, you can't manipulate it through any kind of API.

System.Configuration

to read/write machine.config.
You can find plenty of samples on MSDN for these.
For that you will need to use System.Configuration like:
http://msdn.microsoft.com/en-us/library/ms151439(VS.80).aspx

Code-Based configuration

features available in Entity Framework 6.
http://msdn.microsoft.com/en-US/data/jj680699

Machine.Web.Administration

If you specifically need to set it in machine.config then Microsoft.Web.Administration is not an option.
Currently MWA only allows you to set it in
root web.config or any other web.config,
however there are no API's to modify machine.config.

If you can set it in the root web.config then you can use MWA
by adding a reference (to windows\system32\inetsrv\Microsoft.Web.Administration.dll)
and using ServerManager::GetWebConfiguration(null) to set it in root web.config.

Где он располагается

new ConfigurationFileMap().MachineConfigFilename;
using System;
using System.Configuration;

namespace test
{
	public class MainClass
	{
		public static int Main(string[] args)
		{
			var path = new ConfigurationFileMap().MachineConfigFilename;
			Console.WriteLine(path);
			return 0;
		}
	}
}

$ mcs -r:System.Configuration main.cs
$ mono main.exe
/etc/mono/4.5/machine.config

Словарик

machine.config
DbProviderFactories
.Net Data provider