我想应用更改以便我可以为我的 C# 3.5 应用程序使用服务器 GC 设置 - 我可以通过编辑 machine.config
文件来做到这一点。
唯一的问题是我不知道那在哪里。
如何在许多不同的机器上以可重复的方式找到该文件的路径
32 位
%windir%\Microsoft.NET\Framework\[version]\config\machine.config
64 位
%windir%\Microsoft.NET\Framework64\[version]\config\machine.config
[version]
应等于 v1.0.3705
、v1.1.4322
、v2.0.50727
或 v4.0.30319
。
v3.0
和 v3.5
仅包含 v2.0.50727
的附加程序集,因此不应有 config\machine.config
。 v4.5.x
和 v4.6.x
存储在 v4.0.30319
中。
您可以在 powershell 中运行它:
[System.Runtime.InteropServices.RuntimeEnvironment]::SystemConfigurationFile
为.net 4输出这个:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config
但是请注意,这可能会根据 .net 是作为 32 位还是 64 位运行而改变,这将分别导致 \Framework\
或 \Framework64\
。
[Runtime.InteropServices.RuntimeEnvironment]::SystemConfigurationFile
。 (这也是 .NET 4.0 的 32 位 路径。64 位位于…\Framework64\…#pedantry)
为了绝对确定,在 ASP.NET 页面上贴一个标签并运行以下代码:
labelDebug.Text = System.Runtime.InteropServices.RuntimeEnvironment.SystemConfigurationFile;
我相信这将毫无疑问!
[System.Runtime.InteropServices.RuntimeEnvironment]::SystemConfigurationFile
中运行它
它半取决于...我的是:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
和
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG
打开 Windows 运行命令。 Shortcut=> windows key + r 键入“microsoft.net” - MS .Net 文件夹打开打开“Framework”/“Framework64”文件夹(基于您的处理器)。选择特定的固件版本文件夹,例如“v4.0.30319” 打开配置文件夹 Machine.config 将在那里可用。干杯。
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
在你的 asp.net 应用程序中使用这个
using System.Configuration;
Response.Write(ConfigurationManager.OpenMachineConfiguration().FilePath);
这是一个迟到的回复,但如果有人仍然希望打开 machine.config
并查看/更新配置,这里有一个使用 powershell 的 IIS 配置示例
$machineConfig = [System.Configuration.ConfigurationManager]::OpenMachineConfiguration()
$deployment = $machineConfig.GetSection("system.web/deployment")
$deplyment.Retail = $true
$machineconfig.save()
您可以在 powershell 中运行它:复制并粘贴到 power shell [System.Runtime.InteropServices.RuntimeEnvironment]::SystemConfigurationFile
我的输出是:C:\Windows\Microsoft.NET\Framework\v2.0.50527\config\machine.config
不定期副业成功案例分享