[英]web.config assembly redirect linked configuration
我有一個 IIS 服務器應用程序,我想在另一個文件中設置綁定重定向,該文件可供我整個系統的其他部分使用。
為此,我已經閱讀了有關linkedConfiguration
的信息。
所以在 web.config 中我有以下重定向:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.9.0" newVersion="5.2.9.0"/>
</dependentAssembly>
</assemblyBinding>
我將其替換為以下內容:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<linkedConfiguration href="file://D:\Dev\IIS\AssemblyBindingRedirects.xml"/>
</assemblyBinding>
而 AssemblyBindingRedirects.xml 的內容是:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.9.0" newVersion="5.2.9.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
不幸的是,這似乎不起作用。 我收到一個錯誤,在運行時檢測到錯誤版本的 Newtonsoft.Json。 我已經檢查過 AssemblyBindingRedirects.xml 是否存在於正確的目錄中並且在運行時存在。
我究竟做錯了什么?
在web.config
中, linkedConfiguration
是runtime
-Element 的子元素。 那就是問題所在。 如果我將它移到runtime
-Element 之外,它就可以工作。
但前提是我在href
-Attribute 中使用完全限定路徑。 如果我嘗試使用相對路徑,它不起作用,因為 web.config 中不允許使用相對路徑
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.