Ocelot is not working with .NET Core 3

Created on 29 Aug 2019  路  13Comments  路  Source: ThreeMammals/Ocelot

Expected Behavior

the following method extension

public static IOcelotBuilder AddOcelot(this IServiceCollection services);
public static IOcelotBuilder AddOcelot(this IServiceCollection services, IConfiguration configuration);

add the Ocelot Gateway to the AspNetCore project.

Actual Behavior

throws an exception

System.TypeLoadException
  HResult=0x80131522
  Message=Could not load type 'Microsoft.Extensions.DependencyInjection.MvcJsonMvcCoreBuilderExtensions' from assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
  Source=Ocelot
  StackTrace:
   at Ocelot.DependencyInjection.OcelotBuilder..ctor(IServiceCollection services, IConfiguration configurationRoot)
   at Ocelot.DependencyInjection.ServiceCollectionExtensions.AddOcelot(IServiceCollection services, IConfiguration configuration)
   at OcelotApiGw.Startup.ConfigureServices(IServiceCollection services) in <path to source code file> line 73
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
   at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass15_0.<BuildStartupServicesFilterPipeline>g__RunPipeline|0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass14_0.<ConfigureServices>g__ConfigureServicesWithContainerConfiguration|0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)

possible related to this

Steps to Reproduce the Problem

  1. Try to add ocelot with the method extension.

Specifications

  • Version: 13.5.2
  • Platform: Windows, .NET Core SDK 3.0 preview8

Most helpful comment

Hi all! Do you know when upgrade to .net core 3.0 will be ready? I think not only I wait for this really important update

All 13 comments

ASP.NET Core team here - this was API was moved to another assembly as part of removing Newtonsoft.Json from the core of the platform.

If you want to keep using this you still can by referencing https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.NewtonsoftJson/3.0.0-preview8.19405.7 but you'll have to cross compile. Please ping me or @pranavkm if you need help with migration to 3.0

This is still an issue, just tried the following combination:

  • Ocelot 13.8.0-alpha0016
  • Microsoft.AspNetCore.Mvc.NewtonsoftJson 3.0.0-preview9.19424.4
  • Microsoft.NETCore.App 3.0.0-preview7-27912-14

Just following the instructions that @rynowak mention, is straightforward run the project with net core 3. I suppose the Ocelot team want to use the new Json native library, but if it help I can do a PR with the project using the Newtonsoft library.

Hi all. Any plan to move asp.net core 3.0 without @rynowak's temporary solution..?

@hikalkan https://github.com/geffzhang/Ocelot/tree/netcore3.0 I'm working on upgrading .net core 3.0 and there are still several unit tests that haven't passed

Thank you @geffzhang for informing me and the community :)

Hi all! Do you know when upgrade to .net core 3.0 will be ready? I think not only I wait for this really important update

same issue faced. waiting for the final solution

I have same issue! is anybody knows .net core 3 version update when will be ready?

yes issue also appears in final 3.0.100

I have a talk on a Microservice solution in ~2 weeks and the solution is using Ocelot with ASP.NET Core 3.0 (https://net.developerdays.pl/microservice-implementation-tools-patterns-practices/).

I don't want to rollback to .net core 2.2 馃槃

Any estimation about the first .net core 3.0 compatible release?
I know this is an open source project. Just kindly asking. Thanks.

Try tracking #1025 for updates.

Is this the problem of dotnetcore3?

Was this page helpful?
0 / 5 - 0 ratings