Asp.net core 使用Newtonsoft序列化时,Swagger无法加载API定义

Asp.net core 使用Newtonsoft序列化时,Swagger无法加载API定义,asp.net-core,json.net,swagger,Asp.net Core,Json.net,Swagger,我正在使用swashback.AspNetCore包来记录我的API。我让它工作了几个星期,直到我开始对一些类进行JSON序列化。现在我在大摇大摆的用户界面中发现一个错误: “加载API定义失败”-获取错误内部服务器错误/swagger/v1/swagger.json 我的日志文件显示以下错误: System.IO.FileLoadException:无法加载文件或程序集 'Newtonsoft.Json,版本=12.0.0.0,区域性=中性, PublicKeyToken=30AD4FE6B2

我正在使用swashback.AspNetCore包来记录我的API。我让它工作了几个星期,直到我开始对一些类进行JSON序列化。现在我在大摇大摆的用户界面中发现一个错误:

“加载API定义失败”-获取错误内部服务器错误/swagger/v1/swagger.json

我的日志文件显示以下错误:

System.IO.FileLoadException:无法加载文件或程序集 'Newtonsoft.Json,版本=12.0.0.0,区域性=中性, PublicKeyToken=30AD4FE6B2A6EED'。找到的程序集清单 定义与程序集引用不匹配。(不适用于 HRESULT:0x8013100)

我更新到Newtonsoft.jsonv12.0.1。 Swagger NuGet软件包是否依赖于以前版本的Newtonsoft

我尝试更新我的整个解决方案以使用Newtonsoft.Json v12.0.1。 我还搜索了Swagger与Newtonsoft之间可能存在的依赖关系,但没有看到任何明确的依赖关系

2019-03-26 17:17:34.573 -04:00 [Information] Request starting HTTP/1.1 GET http://localhost:8080/swagger/index.html  
2019-03-26 17:17:34.680 -04:00 [Information] Request finished in 108.7888ms 200 text/html
2019-03-26 17:17:34.876 -04:00 [Information] Request starting HTTP/1.1 GET http://localhost:8080/swagger/v1/swagger.json  
2019-03-26 17:17:34.898 -04:00 [Information] Request starting HTTP/1.1 GET http://localhost:8080/swagger/favicon-32x32.png  
2019-03-26 17:17:34.916 -04:00 [Information] Sending file. Request path: '"/favicon-32x32.png"'. Physical path: '"N/A"'
2019-03-26 17:17:34.917 -04:00 [Information] Request finished in 18.8478ms 200 image/png
2019-03-26 17:17:35.032 -04:00 [Error] Connection ID ""16573246634629012016"", Request ID ""80001a32-0001-e600-b63f-84710c7967bb"": An unhandled exception was thrown by the application.
System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean mustBeInheritable)
   at System.Reflection.CustomAttribute.IsDefined(RuntimePropertyInfo property, RuntimeType caType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.GetSerializableMembers(Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties(Type type, MemberSerialization memberSerialization)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
   at Swashbuckle.AspNetCore.SwaggerGen.SchemaRegistry.CreateSchema(Type type, Queue`1 referencedTypes)
   at Swashbuckle.AspNetCore.SwaggerGen.SchemaRegistry.GetOrRegister(Type type)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateResponse(ApiResponseType apiResponseType, ISchemaRegistry schemaRegistry)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateResponses(ApiDescription apiDescription, ISchemaRegistry schemaRegistry)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreateOperation(ApiDescription apiDescription, ISchemaRegistry schemaRegistry)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItem(IEnumerable`1 apiDescriptions, ISchemaRegistry schemaRegistry)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItems(IEnumerable`1 apiDescriptions, ISchemaRegistry schemaRegistry)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath, String[] schemes)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()


2019-03-26 17:17:35.058 -04:00 [Information] Request finished in 182.3632ms 500 
我希望招摇过市页面像往常一样列出我的HTTP方法