我有一個包含大約 100 個項目的解決方案。我不知道究竟是什么觸發了它,但 Visual Studio 偶爾會向我的每個項目添加一個 app.config。它通??雌饋硐襁@樣:<?xml version="1.0" encoding="utf-8"?><configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime></configuration>據我所知,不需要這些 app.config 文件。如果我恢復所有這些更改并刪除 app.config 文件,一切似乎都正常。為什么 Visual Studio 這樣做,我怎樣才能讓它停止?
1 回答
冉冉說
TA貢獻1877條經驗 獲得超1個贊
通常 VS 會在您更新 nuget 包時添加這些配置(綁定重定向)。它有助于防止 .NET 在尋找依賴項時出現一些問題,例如
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
在此配置中,我們談到如果您的應用程序的其他一些依賴項引用了版本低于 11.0.0.0 的程序集,則它們應該使用版本 11.0.0.0。在這種情況下,如果您省略此綁定重定向,您將在運行時出現異常。
如果您的應用程序中沒有此類依賴項,則可以刪除這些配置。
- 1 回答
- 0 關注
- 267 瀏覽
添加回答
舉報
0/150
提交
取消
