3

我想以与许多文章和微软建议的完全相同的方式将此部分添加到我的 machine.config 中:

  <configuration>
    <system.net>
       <connectionManagement>
         <add name = "www.contoso.com" maxconnection = "4" />
         <add name = "*" maxconnection = "2" />
       </connectionManagement>
     </system.net>
 </configuration>

http://msdn.microsoft.com/en-us/library/aa903351(v=vs.71).aspx http://geekswithblogs.net/StuartBrierley/archive/2009/09/30/tuning-iis--- machine.config-settings.aspx

但是,一旦我这样做,当我尝试访问同一台机器上 IIS 上托管的页面时,就会出现此异常:

解析器错误消息:无法识别的配置部分 system.net。

源错误:

Line 9:      settings that differ from their defaults.
Line 10: --><configuration>
Line 11:  <system.net>
Line 12:          <connectionManagement>
Line 13:              <add address="*" maxconnection="24" />

源文件:C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Config\machine.config

线路:11

问题出在哪里,如何修改 machine.config 以便最终控制该maxconnection值?

4

4 回答 4

2

在我的 machine.config 中,第 10 行仍然是开篇评论的一部分。你把那些删了吗?

--> 表示您可能没有删除结束 xml 注释,或者您可能不小心删除了开始 xml 注释标记。确保你有开口<!--

编辑:

你有开放的 xml 标头吗?行号关闭的事实对我来说似乎很奇怪。第 9 行应该是更高的一行。它应该是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Please refer to machine.config.comments for a description and
    the default values of each configuration section.

    For a full documentation of the schema please refer to
    http://go.microsoft.com/fwlink/?LinkId=42127

    To improve performance, machine.config should contain only those
    settings that differ from their defaults.
-->
于 2011-03-31T14:53:30.173 回答
1

解决方法是在配置文件中的这一行之后移动配置部分:

  <sectionGroup name="system.net" type="System.Net.Configuration.NetSectionGroup, ...

这似乎有助于解决问题。

于 2011-03-31T15:41:07.967 回答
0

如果您将问题中的 XML 按原样添加到配置文件中,那就有问题了。

configuration应该是(单个)根元素,system.net如果它不存在,则应在其下添加 - under configuration

如果确实存在,请connectionManagement在现有部分中添加该system.net部分。

如果已经存在,请添加或修改现有add标签。

于 2011-03-31T15:04:18.510 回答
0

确认您没有在元素system.net之前添加该部分configSections

配置文件中存在的configSections元素必须是 machine.config 的第一个子元素,configuration并且您应该configSections定义元素。


免责声明:我回答了这个问题,却没有意识到它已经在八个月前被问过,并且 OP 已经找到了解决问题的方法。由于他的回答给出了解决方案而没有解释原因,所以我决定不删除我的答案,现在我有一个比答案更大的免责声明......我真的应该开始更加关注了。

于 2011-12-05T12:53:57.330 回答