Asp.net core System.IO.FileLoadException不匹配

Asp.net core System.IO.FileLoadException不匹配,asp.net-core,nuget-package,asp.net-core-1.0,Asp.net Core,Nuget Package,Asp.net Core 1.0,我正在尝试创建一个新的ASP.net核心应用程序,但问题是我构建的每个应用程序都会出现以下错误消息: PM> add-migration Init System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located a

我正在尝试创建一个新的ASP.net核心应用程序,但问题是我构建的每个应用程序都会出现以下错误消息:

PM> add-migration Init
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Microsoft.Extensions.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at Microsoft.EntityFrameworkCore.Design.Internal.StartupInvoker.ConfigureHostServices(IServiceCollection services)
   at Microsoft.EntityFrameworkCore.Design.Internal.StartupInvoker.ConfigureServices()
   at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations..ctor(IOperationReporter reporter, Assembly assembly, Assembly startupAssembly, String environment, String contentRootPath)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations..ctor(IOperationReporter reporter, Assembly assembly, Assembly startupAssembly, String environment, String projectDir, String contentRootPath, String rootNamespace)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.<>c__DisplayClass4_0.<.ctor>b__4()
   at Microsoft.EntityFrameworkCore.Internal.LazyRef`1.get_Value()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Could not load file or assembly 'Microsoft.Extensions.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

正如Daniel J.G.所说,我也需要更新project.json,如下所示:

{
  "userSecretsId": "secret",

  "runtimes": {
    "win10-x64": {}
  },

  "dependencies": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
    "Microsoft.NETCore.App": "1.1.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0"
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8"
      ]
    }
  },

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

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

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

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

  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}
之后,我还需要指定我的deps.json

PM> add-migration init
The specified deps.json [C:\Users\ik_ro\Source\Repos\ProjectDotNetCoreTest\src\ProjectDotNetCoreTest\bin\Debug\netcoreapp1.1\ProjectDotNetCoreTest.deps.json] does not exist
Process finished with non-zero exit code
PM> add-migration init
The specified framework 'Microsoft.NETCore.App', version '1.1.0' was not found.
  - Check application dependencies and target a framework version installed at:
    C:\Program Files\dotnet\shared\Microsoft.NETCore.App
  - The following versions are installed:
    1.0.1
  - Alternatively, install the framework version '1.1.0'.
Process finished with non-zero exit code
它搜索的位置是:

 C:\Users\ik_ro\Source\Repos\ProjectDotNetCoreTest\src\ProjectDotNetCoreTest\bin\Debug\netcoreapp1.1\win10-x64
但它必须是:

C:\Users\ik_ro\Source\Repos\ProjectDotNetCoreTest\src\ProjectDotNetCoreTest\bin\Debug\netcoreapp1.1\win10-x64

我将win10-x64文件夹中的所有内容复制并粘贴到netcoreapp1.1文件夹。这就解决了问题

显示您的project.json-可能您正在混合软件包版本。我现在用我的project.json更新了帖子。你可能会有一个想法?在框架内,它应该是
netcoreapp1.1
,根据(不确定这是否是原因)O兄弟,这就是诀窍!非常感谢你!
C:\Users\ik_ro\Source\Repos\ProjectDotNetCoreTest\src\ProjectDotNetCoreTest\bin\Debug\netcoreapp1.1\win10-x64