0

After upgrading to netcoreapp1.0 I'm not able to run my project. I've resolved all errors and fixes for the update, restored packages and get no errors anywhere.

(I followed this guide for upgrading https://learn.microsoft.com/en-us/dotnet/articles/core/migrating-from-dnx)

All I get is the classic Object reference not set to an instance of an object. which kind of drives me nuts.

Run command

$ dotnet run
Object reference not set to an instance of an object.

My tools:

$ dotnet --info

.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
 Version:            1.0.0-preview2-003121
 Commit SHA-1 hash:  1e9d529bc5

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.10
 OS Platform: Darwin
 RID:         osx.10.10-x64

(Also ran on my Win 10 box with the same result, unable to run from cmd or visual studio as well)

The --log 4 doesn't output anything either.

Any ideas on how to nail it down?

UPDATE:

project.json

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "System.Diagnostics.Process" : "4.1.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },

  "tooling": {
    "defaultNamespace": "Avantime.Sniff"
  }
}
Jonas Stensved
  • 14,378
  • 5
  • 51
  • 80

1 Answers1

0

Not sure what caused the error above but after reading various release notes on github and minor fixes this was the needed adjustments to get it working.

Also with a lot of work removing all references to old libraries depending on older code than netcore50 (mostly updating EF7 to EntityFrameworkCore) in code.

My fixes:

Added Program.cs as new entry point for application

public static class Program
    {
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            host.Run();

        }
    }

Fixed Startup signature according to this: https://github.com/aspnet/Announcements/issues/171

        public Startup(IHostingEnvironment env)
        {
            // Setup configuration sources.
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("config.json");

            [...]

Changed package.json to

{
  "dependencies": {
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Mvc.Core": "1.0.0",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.Session": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.NETCore.Runtime.CoreCLR": "1.0.2", <-- IMPORTANT
    "Microsoft.Extensions.PlatformAbstractions": "1.0.0" <-- IMPORTANT
  },

  "buildOptions": {
    "compile": {
      "include": [
        "../../shared/**/*.cs"
      ]
    },
    "copyToOutput": {
      "include": [
        "Areas",
        "Views",
        "wwwroot",
        "config.json",
        "web.config"
      ]
    },
    "define": [
      "DEMO",
      "TESTING"
    ],
    "emitEntryPoint": true, <- IMPORTANT
    "preserveCompilationContext": true,
    "warningsAsErrors": false
  },
  "publishOptions": {
    "include": [
      "Areas",
      "Views",
      "wwwroot",
      "config.json",
      "web.config"
    ]
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "Microsoft.NETCore.App": {
        "version": "1.0.0-*",
        "type": "platform"
      },
      "imports": [ "netcore50", "portable-net452+win81" ] <- IMPORTANT
    }

  },
  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*"
  },
  "scripts": {
    "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
  },
  "webroot": "wwwroot",
  "version": "1.0.0-*",
  "runtimes": {
    "win10-x64": {}
  }
}
Jonas Stensved
  • 14,378
  • 5
  • 51
  • 80