I wish to add Swagger to my asp.net REST service using Swashbuckle as outlined here.
I went through all the steps, and since I am using Owin I have both Swashbuckle
and Swashbuckle.Core
nugets installed.
However, when I run, and navigate to http://localhost/myapp/swagger
I get the following error..
Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
I have version 5.2.4.01
of this DLL so I added the following redirects
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="4.0.0.0" newVersion="5.2.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.2.4.0" />
</dependentAssembly>
I also added the System.Net.Http.Formatting
redirect as I saw this mentioned in another post (but it made no difference)
I still get an error as below...
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///D:/dev/myapp/trunk/myapp/
LOG: Initial PrivatePath = D:\dev\myapp\trunk\myapp\bin
Calling assembly : Swashbuckle.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cd1bb07a5ac7c7bc.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\dev\myapp\trunk\myapp\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.0 redirected to 5.2.3.0.
LOG: Post-policy reference: System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/myappdev/0d9cef3e/aedd2787/System.Web.Http.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/myappdev/0d9cef3e/aedd2787/System.Web.Http/System.Web.Http.DLL.
LOG: Attempting download of new URL file:///D:/dev/myapp/trunk/myapp/bin/System.Web.Http.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
I can see it is trying to use the redirected file, and I have check this file is in my bin
folder, but, as above, it still does not work.
I have the following included my packages.config
...
...
<package id="Microsoft.AspNet.Cors" version="5.2.4" targetFramework="net47" />
<package id="Microsoft.AspNet.WebApi" version="5.2.4" targetFramework="net47" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.4" targetFramework="net47" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.4" targetFramework="net47" />
<package id="Microsoft.AspNet.WebApi.Cors" version="5.2.4" targetFramework="net47" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.4" targetFramework="net47" />
<package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.4" targetFramework="net47" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.4" targetFramework="net47" />
...
<package id="Swashbuckle" version="5.6.0" targetFramework="net47" />
<package id="Swashbuckle.Core" version="5.6.0" targetFramework="net47" />
...
Does anyone have any suggestions on what else I can try here?
Thanks in advance!