I am unable to start up my asp.net core application after trying to port it to 1.0 RC2 from 1.0 RC1. The startup error I get is this:
Unhandled Exception: System.Exception: Could not resolve a service of type 'Microsoft.Extensions.Configuration.IConfiguration' for the parameter 'configuration' of method 'Configure' on type 'MYCOMPANY.MYTHING.Api.Startup'.
at Microsoft.AspNetCore.Hosting.Startup.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at MYCOMPANY.MYTHING.Api.Program.Main(String[] args)
I can't figure out how this is supposed to work.
The parts I do understand are:
My startup.cs code looks correct to me, in Startup(IHostingEnvironment env) I create a ConfigurationBuilder and set Startup.Configuration equal to builder.Build(). The ConfigureServices method is also reached and Configuration object exists there.
When the host.Run() code is reached in Program.cs, I get a crash.
Configure(app,env,loggerFactory,configuration,respository...) method is NEVER reached.
In RC1 there used to be a line like this:
services.AddInstance<IConfiguration>(Configuration);
In RC2 that doesn't exist anymore in a new application (I am reading a new application which works and trying to compare line by line).
I have been looking for how to make this work, and how to understand dependency injection of the IConfigurationRoot, but I don't see any attribute or code that seems to be responsible for this injection.
Update: It seems that I was using some strange pattern in my RC1 code that is no longer supported in RC2. After I removed some additional parameters from my Configure() method it was once again invoked by the .net core startup code.