【问题标题】:How do you update FX_schema.xml file in IIS 7?如何在 IIS 7 中更新 FX_schema.xml 文件?
【发布时间】:2010-11-04 13:56:57
【问题描述】:

我们正在将 ASP.Net MVC 应用程序部署到运行 IIS 7.5 的 Windows 2008 R2 服务器。

部署后,我们在事件日志中收到此错误(我们还会收到一封电子邮件): c:\wwwroot\web.config 中第 x 行上的“无法识别的元素 'providerOption'” 即:

<providerOption name="CompilerVersion" value="v3.5"> 

位于我们标准网络配置的 system.codedom 编译器部分。我稍微调查了一下这个问题。 (我还查看了namespace details on msdn 以了解有关它的信息)。在许多其他解决方案中,我发现this post 建议更新我们服务器上的 FX_Schema.xml 文件。 (我觉得问题就出在这里,如果我弄错了,请纠正我)

我查看了 fx_schema 文件,并且根据事件查看器中的定义,属性“providerOption”不在此模式中!这是 FX_schema.xml 中 system.codedom 部分的副本

<sectionSchema name="system.codedom">
    <element name="compilers">
        <collection addElement="compiler" removeElement="remove" clearElement="clear">
            <attribute name="language" type="string" isCombinedKey="true" />
            <attribute name="extension" type="string" isCombinedKey="true" />
            <attribute name="type" type="string" />
            <attribute name="warningLevel" type="int" />
            <attribute name="compilerOptions" type="string" />
        </collection>
    </element>
</sectionSchema>

我确信我不会是唯一遇到此问题的人,但有其他人之前遇到过此问题并找到解决方案吗?

编辑:另一种快速生成的方法是(在 Windows 7 中的 IIS 7 上)

在 IIS 管理控制台中,在网站主页中打开您的 MVC 网站。您应该看到 ASP.NET、IIS 和管理组。在管理下,打开“配置编辑器”。我收到这里弹出的错误消息!

编辑:我的网络配置副本:

<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
            type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
         <providerOption name="CompilerVersion" value="v3.5"/>
         <providerOption name="WarnAsError" value="false"/>
    </compiler>

  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4"
            type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="OptionInfer" value="true"/>
    <providerOption name="WarnAsError" value="false"/>
      </compiler>
   </compilers>

【问题讨论】:

  • 没人会帮我吗?可能需要等待下一次windoes更新...... :-(
  • 无法轻易解决这个问题,看来唯一的办法是将我们的项目升级到.net 4,这需要一些时间。我已经接受了布赖恩的工作,直到找到更好的解决方案。

标签: asp.net asp.net-mvc xml deployment iis-7


【解决方案1】:

我已经设法通过简单地转到配置管理器的 system.codedom 部分在 IIS 中重新创建错误。

使用 .net3.5 或 .net4.0 应用程序我没有收到任何错误,但这些都是非常基本的测试应用程序,也只有 .net3.5 测试应用程序在 web.config 中放置了 system.codedom 部分默认文件。 .net4.0 简化了 web.config 文件并移出了很多选项

我找到了一些信息here,关于可能有用的配置冲突

推荐

第二种情况的解决方法 是删除或注释掉所有 system.web.extensions配置 部分定义和配置 部分组定义来自 应用程序级 Web.config 文件。 这些定义通常在 应用层的顶部 Web.config 文件并可以识别 通过 configSections 元素及其 孩子们。

对于这两种情况,建议 您还手动删除 system.codedom 部分,虽然这 不需要

不完全相同的问题,但相似

【讨论】:

  • 是的,当你创建一个新的 MVC 项目时,该文件会自动生成。我还没有编辑过。如果你做一个测试 MVC 项目,你会得到同样的错误吗?
  • 感谢布莱恩的帮助,但我仍然无法正常工作。毫无疑问,删除 system.codedom 部分将根据架构验证 web.config。但事实上 MVC 2 (with .net3.5) 项目会自动为我生成 web.config 代码,我喜欢将其视为一个小错误。基本上,有人忘记根据架构验证此版本项目的 web.config。 :(
【解决方案2】:

我有一个与我发布的非常相似的问题,然后我自己解决并发布了解决方案I came up with。我的解决方案:我制作了自己的文件并将其与架构文件一起放入。我将其命名为 ThreeFive.xml,并将其放置在 C:\Windows\System32\inetsrv\config\schema。该文件的全部内容如下:

<configSchema>
    <sectionSchema name="system.codedom">
        <element name="compilers">
            <collection addElement="compiler" removeElement="remove" clearElement="clear">
                <attribute name="language" type="string" isCombinedKey="true" />
                <attribute name="extension" type="string" isCombinedKey="true" />
                <attribute name="type" type="string" />
                <attribute name="warningLevel" type="int" />
                <attribute name="compilerOptions" type="string" />
                <collection addElement="providerOption">
                  <attribute name="name" required="true" isUniqueKey="true" type="string" />
                  <attribute name="value" required="true" type="string" />
                </collection>
            </collection>
        </element>
    </sectionSchema>
</configSchema>

然后我发布了一个 3.5 站点,该站点从 appconfig 设置中检索信息并执行了一些 LINQ 以确保配置和 3.5 生效。配置文件没有空白,LINQ 正在按预期工作,所以我很想将此称为解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-17
    • 1970-01-01
    • 2011-08-03
    • 1970-01-01
    • 1970-01-01
    • 2017-03-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多