如何在Web.config转换

时间:2018-01-10 20:49:33

标签: xml xslt web-config-transform

我正在尝试将dependentAssembly元素插入到我的配置中,其中子assemblyIdentity元素已经不存在。但是,我收到以下错误

  

源文档中没有元素匹配   ' /配置/运行/ _defaultNamespace:assemblyBinding / _defaultNamespace:dependentAssembly [assemblyIdentity / @名称=' System.Web.Extensions程序']'

在我的配置文件和转换文件的相关片段下面。在Xslt转换中是否有任何大师可以提供帮助?

示例转换

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
   <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly xdt:Transform="InsertIfMissing" xdt:Locator="Condition(assemblyIdentity/@name='System.Web.Extensions')">
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" xdt:Transform="SetAttributes" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

示例配置

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
<configuration>

0 个答案:

没有答案