Where Is Machine. Config?
I Want to Apply a Change So That I Can Use Server Gc Settings for My C# 3.5 App - I Can Do That by Editing the Machine. Config File. the Only Problem Is I Do...
I want to apply a change so That I can use Server GC settings for my C# 3.5 app - I can do that by editing the machine.config file.
The only problem is I do not know where that is.
How can I find the path of this file in a repeatable way across a number of different machines
9 Answers
32-bit
%windir%\Microsoft.NET\Framework\[version]\config\machine.config
64-bit
%windir%\Microsoft.NET\Framework64\[version]\config\machine.config
[version] should be equal to v1.0.3705, v1.1.4322, v2.0.50727 or v4.0.30319.
v3.0 and v3.5 just contain additional assemblies to v2.0.50727 so there should be no config\machine.config. v4.5.x and v4.6.x are stored inside v4.0.30319.
You can run this in powershell:
[System.Runtime.InteropServices.RuntimeEnvironment]::SystemConfigurationFile
Which outputs this for .net 4:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config
Note however that this might change depending on whether .net is running as 32 or 64 bit which will result in \Framework\ or \Framework64\ respectively.
In order to be absolutely sure, slap a Label on an ASP.NET page and run this code:
labelDebug.Text = System.Runtime.InteropServices.RuntimeEnvironment.SystemConfigurationFile;
I believe this will leave no doubt!
It semi-depends though... mine is:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
and
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG
- Open Windows Run command. Shortcut=> windows key + r
- Type "microsoft.net" - MS .Net folder opens up
- Open "Framework"/"Framework64" folder(based on your processor).
- Select specific FW version folder e.g. "v4.0.30319"
- Open config folder
- Machine.config will be available there. Cheers.
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
In your asp.net app use this
using System.Configuration;
Response.Write(ConfigurationManager.OpenMachineConfiguration().FilePath);
This is a late reply, but if anyone is still looking to open machine.config and view/update configs, here's an example with IIS config using powershell
$machineConfig = [System.Configuration.ConfigurationManager]::OpenMachineConfiguration()
$deployment = $machineConfig.GetSection("")
$deplyment.Retail = $true
$machineconfig.save()
You can run this in powershell: copy & paste in power shell [System.Runtime.InteropServices.RuntimeEnvironment]::SystemConfigurationFile
mine output is: C:\Windows\Microsoft.NET\Framework\v2.0.50527\config\machine.config