Skip to content

Support ASP.NET Core 3.0  #206

@shahabganji

Description

@shahabganji

I am planning to move to asp.net core 3.0, but I got an error message which sounds to be due to breaking changes in asp.net core 3.0.

Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'Microsoft.Extensions.DependencyInjection.ServiceCollection' to type 'Grace.DependencyInjection.IInjectionScope'.
   at Microsoft.Extensions.Hosting.Internal.ConfigureContainerAdapter`1.ConfigureContainer(HostBuilderContext hostContext, Object containerBuilder)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at dry_test.Program.Main(String[] args) in /../Program.cs:line 20

Startup.cs file:

// omitted code

 public void ConfigureContainer(IInjectionScope scope)
        {
            scope.SetupMvc();
            scope.Configure(c=> c.Export<SampleService>().As<ISample>());
        }

// omitted code

Program.cs file:

 public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                    webBuilder.UseGrace();
                });

Any changes I need to make, or should wait until final version of 3.0?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions