What could be the reason for following errors:
1> Unhandled Exception: System.TypeLoadException: Method 'Negotiate' in type 'Api.JsonContentNegotiator' from assembly 'Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
1> at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
1> at System.Reflection.RuntimeAssembly.GetExportedTypes()
1> at System.Reflection.Assembly.get_ExportedTypes()
1> at NSwag.SwaggerGeneration.WebApi.WebApiToSwaggerGenerator.GetControllerClasses(Assembly assembly)
1> at Program.Main(String[] args)
Of course the method is implemented and the Api project builds correctly.
I think I had same issue once, and I had to do some cleanup with dlls then, however I am not able to fix this today. What could be the root cause of presented issue?
It seems that generator and api.dll were referencing different version of the same assembly (net.http or net.http.formatting). Downgrading one used by api.dll solved the issue.
Once i had the same problem in a project. Cant this also be fixed with binding redirects?
Adding
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
to the Web.config solved this problem.
Thanks for reporting here.
Most helpful comment
Adding
to the Web.config solved this problem.