rbeauchamp / Swashbuckle.OData

Extends Swashbuckle with OData v4 support!
Other
129 stars 96 forks source link

Swashbuckle.OData.HttpConfigurationExtensions threw an exception. "ExceptionType":"System.TypeInitializationException" #164

Closed BryanWilhite closed 5 years ago

BryanWilhite commented 6 years ago

We are getting this exception:

500 : {"Message":"An error has occurred.","ExceptionMessage":"The type initializer for 'Swashbuckle.OData.HttpConfigurationExtensions' threw an exception.","ExceptionType":"System.TypeInitializationException","StackTrace":" at Swashbuckle.OData.HttpConfigurationExtensions.SerializerSettingsOrDefault(HttpConfiguration httpConfig)\r\n at Swashbuckle.OData.ODataSwaggerProvider.GenerateSwagger(String rootUrl, String apiVersion) in C:\\Users\\rbeauchamp\\Documents\\GitHub\\Swashbuckle.OData\\Swashbuckle.OData\\ODataSwaggerProvider.cs:line 63\r\n at Swashbuckle.OData.ODataSwaggerProvider.GetSwagger(String rootUrl, String apiVersion) in C:\\Users\\rbeauchamp\\Documents\\GitHub\\Swashbuckle.OData\\Swashbuckle.OData\\ODataSwaggerProvider.cs:line 56\r\n at Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"Could not load file or assembly 'System.Web.OData, Version=6.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)","ExceptionType":"System.IO.FileLoadException","StackTrace":" at Swashbuckle.OData.HttpConfigurationExtensions..cctor()"}} http://localhost:56744/swagger/docs/v2

We do not find this issue when we ran Microsoft.AspNet.OData 6.0.0 and will roll back for immediate relief.

These are all the packages in play:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="AutoMapper" version="6.1.1" targetFramework="net452" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net45" />
  <package id="EPPlus" version="4.1.0" targetFramework="net452" />
  <package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.OData" version="6.1.0" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebApi" version="5.0.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Cors" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.OData" version="5.7.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.Data.Edm" version="5.8.3" targetFramework="net452" />
  <package id="Microsoft.Data.OData" version="5.8.3" targetFramework="net452" />
  <package id="Microsoft.Extensions.DependencyInjection" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.OData.Core" version="7.3.1" targetFramework="net452" />
  <package id="Microsoft.OData.Edm" version="7.3.1" targetFramework="net452" />
  <package id="Microsoft.Spatial" version="7.3.1" targetFramework="net452" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
  <package id="Net.Http.WebApi.OData" version="3.4.1" targetFramework="net452" />
  <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
  <package id="Oracle.ManagedDataAccess" version="12.2.1100" targetFramework="net45" />
  <package id="Oracle.ManagedDataAccess.EntityFramework" version="12.2.1100" targetFramework="net45" />
  <package id="Swashbuckle" version="5.6.0" targetFramework="net452" />
  <package id="Swashbuckle.Core" version="5.6.0" targetFramework="net452" />
  <package id="Swashbuckle.OData" version="3.4.0" targetFramework="net452" />
  <package id="System.Collections" version="4.3.0" targetFramework="net452" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net452" />
  <package id="System.ComponentModel" version="4.3.0" targetFramework="net452" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net452" />
  <package id="System.Globalization" version="4.3.0" targetFramework="net452" />
  <package id="System.Linq" version="4.3.0" targetFramework="net452" />
  <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net452" />
  <package id="System.Reflection" version="4.3.0" targetFramework="net452" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net452" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net452" />
  <package id="System.Spatial" version="5.8.3" targetFramework="net452" />
  <package id="System.Threading" version="4.3.0" targetFramework="net452" />
  <package id="System.Threading.Tasks" version="4.3.0" targetFramework="net452" />
  <package id="WebActivatorEx" version="2.2.0" targetFramework="net45" />
</packages>
kantnisha commented 6 years ago

Is there an update on this?

phpollack commented 6 years ago

I have the same problem. Swashbuckle.OData 4.0.0-beta2 Microsoft.AspNet.OData 7.0.0 (no problems with 6)

mdgiles commented 5 years ago

Same problem.

karpediemnow commented 5 years ago

Same problem :(

icnocop commented 5 years ago

@andyward published Swashbuckle.OData.Core that resolves this issue.

First remove the Swashbuckle.OData package and then install the Swashbuckle.OData.Core package.

I used v1.0.0 of the NuGet package and it worked without issues.

Microsoft.AspNet.OData v7.0.1.

Thank you, @andyward! :smile:

His fork can be found here: https://github.com/andyward/Swashbuckle.OData

andyward commented 5 years ago

Just for full disclosure that's not a Nuget package I personally published, although it appears to be based on the fork I created to support OData 7 as per #191 .