San*_*Rao 1 c# wcf asp.net-mvc-3 asp.net-web-api swagger
我开始通过下载 Swashbuckle 来运行项目“Swashbuckle.Dummy.SelfHost”。然后我转到浏览器并检查在program.cs类的主函数中声明的URL。当我在浏览器中给出相同的URL(例如“http:/ localhost:8090/swagger”)时,我收到以下错误。任何人都可以指导我逐步运行旋转扣解决方案并进行测试吗?如果我想在 IIS 上托管此应用程序并运行,我需要遵循哪些步骤?
An error has occurred.
Could not load file or assembly 'System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
System.IO.FileLoadException
at Swashbuckle.Application.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Web.Http.HttpServer.<>n__FabricatedMethod9(HttpRequestMessage , CancellationToken ) at System.Web.Http.HttpServer.d__0.MoveNext()
Run Code Online (Sandbox Code Playgroud)
问题是 Swashbuckle 在版本 4 中使用 System.Web.Http 和 System.Net.Http.Formatting 程序集。我假设您的应用程序正在使用 ASP MVC 5.x。在这种情况下,您必须将绑定重定向添加到 web.config 中。将以下部分添加到您的 web.config 中(将“5.0.0.0”与您的应用程序实际引用的上述程序集的版本交换):
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6744 次 |
| 最近记录: |