Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Application will not start once I follow new means for creating Configuration #191

@mgbee8

Description

@mgbee8

I am incrementally building and application starting from empty.
Once I add the new means of constructing a Configuration object as described here:
Announcements

I receive the following error:

System.InvalidOperationException: No service for type 'Microsoft.Framework.Runtime.IApplicationEnvironment' has been registered.
   at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNet.Hosting.WebHostBuilder.Build()
   at Microsoft.AspNet.Hosting.Program.Main(String[] args)

Here is my startup file

using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.ConfigurationModel;
using Microsoft.AspNet.Hosting;
using Microsoft.Framework.Runtime;

namespace Demo2
{
public class Startup
{
    IConfiguration Configuration { get; set; }

    public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
    {
        // Setup configuration sources.
        var configuration = new Configuration(appEnv.ApplicationBasePath)
            .AddJsonFile("config.json");
        configuration.AddEnvironmentVariables();
        Configuration = configuration;

    }
    public void ConfigureServices(IServiceCollection services)
    {
    }

    public void Configure(IApplicationBuilder app)
    {
        app.Run(async (context) =>
        {
            await context.Response.WriteAsync("Hello World!");
        });
    }
}
}

And here is my project.json:
{
webroot": "wwwroot",
"version": "1.0.0-*",

"dependencies": {
    "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta5-11269", 
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta5-11700",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5-12086"
},

"commands": {
  "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000"
} ,

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },

  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],
  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ]
}

Any help would be appreciated, ran dnvm upgrade, no change, attempted to run dnx with debug flag and received same response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions