0

にアップグレードした後netcoreapp1.0、プロジェクトを実行できません。アップデートのすべてのエラーと修正を解決し、パッケージを復元しましたが、どこにもエラーはありません。

( https://docs.microsoft.com/en-us/dotnet/articles/core/migrating-from-dnxのアップグレードについては、このガイドに従いました)

私が得たのは、Object reference not set to an instance of an object.私を夢中にさせるクラシックだけです。

コマンドを実行

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

私のツール:

$ 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

(Win 10ボックスでも同じ結果で実行され、cmdまたはビジュアルスタジオからも実行できません)

--log 4も何も出力しません。

それを釘付けにする方法についてのアイデアはありますか?

アップデート:

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"
  }
}
4

1 に答える 1

0

上記のエラーの原因は不明ですが、github に関するさまざまなリリース ノートとマイナーな修正を読んだ後、これを機能させるために必要な調整でした。

また、コード内の netcore50 よりも古いコード (主に EF7 を EntityFrameworkCore に更新する) に応じて、古いライブラリへのすべての参照を削除するという多くの作業が必要です。

私の修正:

Program.csアプリケーションの新しいエントリ ポイントとして追加

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

            host.Run();

        }
    }

Startupこれに従って署名を修正しました: https://github.com/aspnet/Announcements/issues/171

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

            [...]

package.json を次のように変更しました

{
  "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": {}
  }
}
于 2016-07-15T09:22:11.027 に答える