部署ASP.NET Core 1.1.0和實體框架核心1.1:無法加載程序集system.Collections.Immutable,Version = 1.1.37.0

asp.net-core asp.net-core-1.1 entity-framework-core

我將我的項目遷移到ASP.NET Core 1.1.0和Entity Framework Core 1.1,所有這些都在開發中運行良好。

但是不能在staging中部署項目,我從stdout日誌中得到這個錯誤:

應用程序啟動異常:System.IO.FileLoadException:Impossible de charger le fichier ou l'assembly'Microsoft.Extensions.DependencyInjection.Abstractions,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = adb9793829ddae60'ou une de sesd“pendances。 Lad’定義的故事,對應於過去的大會。 (Exception de HRESULT:0x80131040)Nomdefichierÿ:'Microsoft.Extensions.DependencyInjection.Abstractions,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = adb9793829ddae60'
Ag | Agata.Presentation.Web.Startup.ConfigureServices(IServiceCollection services)--- Fin de la trace de la pile - partir de l'emplacementpr’“tenau niveau duquel l'exception ašt†šlev’--- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() - Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) - Microsoft.AspNetCore.Hosting.Internal.WebHost。 EnsureApplicationServices() - Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

我檢查了解決方案中包含的所有項目中的所有nuget包,所有依賴項都是最新的。

我已經刪除了所有staging的目錄並完全重新部署它以確保沒有舊的dll但錯誤仍在這裡。我也多次重啟IIS池和網站。

並且.NET Core 1.1.0安裝在服務器上。

任何人都知道這裡發生了什麼?

編輯:這是我的project.json:

 "dependencies": {
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview3-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0-preview3-final",
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.0.0-preview3-final",
    "Npgsql": "3.1.6",
    "Remotion.Linq": "2.1.1",
    "Serilog.Sinks.RollingFile": "3.2.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "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.Binder": "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.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Serilog.Extensions.Logging": "1.3.0",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.EntityFrameworkCore": "1.1.0",
    "System.Interactive.Async": "3.1.0",
    "Microsoft.Extensions.DependencyInjection.Abstractions": "1.1.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"
  },

  "tools": {
    "Microsoft.Extensions.SecretManager.Tools": "1.1.0-preview4-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.1.0-preview4-final"
  },

編輯:問題現在不同了,現在的錯誤是:

應用程序啟動異常:System.IO.FileLoadException:Impossible de charger le fichier ou l'assembly'System.Interactive.Async,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 94bc3704cddfc263'ou une de sesd“pendances。 Lad’定義的故事,對應於過去的大會。 (Exception de HRESULT:0x80131040)Nomdefichierÿ:'System.Interactive.Async,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 94bc3704cddfc263''Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServiceCollectionExtensions.AddQuery(IServiceCollection serviceCollection)â €| Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServiceCollectionExtensions.AddEntityFramework(IServiceCollection serviceCollection) - Microsoft.EntityFrameworkCore.Infrastructure.RelationalServiceCollectionExtensions.AddRelational(IServiceCollection services) - Microsoft.Extensions.DependencyInjection.SqlServerServiceCollectionExtensions.AddEntityFrameworkSqlServer(IServiceCollection services)â€| Agata.Presentation.Web.Startup.ConfigureServices(IServiceCollection services)dans C:\ Workspace \ PerformancesEtControles \ Agata \ DevLot1 \ Presentation \ Agata.Presentation.Web \ Startup.cs:ligne 65 --- Fin de la trace de lapileâ €| partir de l'emplacementpr’s dent au niveau duquel l'exception a ????lev’System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() - Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)â €| Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() - Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

這是我更新的project.json:

 "dependencies": {
    "Npgsql": "3.1.6",
    "Remotion.Linq": "2.1.1",
    "Serilog.Sinks.RollingFile": "3.2.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "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.Binder": "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.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Serilog.Extensions.Logging": "1.3.0",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.EntityFrameworkCore": "1.1.0",
    "Microsoft.Extensions.DependencyInjection.Abstractions": "1.1.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
    "System.Interactive.Async": "3.1.0"
  },

  "tools": {
    "Microsoft.Extensions.SecretManager.Tools": "1.1.0-preview4-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.1.0-preview4-final"
  },

我的啟動文件的第65行是:

services.AddEntityFrameworkSqlServer().AddDbContext<MyDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("MyDbConnectionString")));

它在視覺工作室的調試中仍能正常工作......

編輯2:我解決了System.Interactive.Async更新Serilog.Extensions.Logging包...我現在有錯誤:

System.IO.FileLoadException:Impossible de charger le fichier ou l'assembly'System.Collections.Immutable,Version = 1.1.37.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'ou une desesdépend。 Ladéfinitiontrouvéedu manifeste de l'assembly ne對應paséraéférencede l'assembly。 (Exception de HRESULT:0x80131040)Nom de fichier:'System.Collections.Immutable,Version = 1.1.37.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'
ÃMicrosoft.AspNetCore.Mvc.Razor.Internal.RazorReferenceManager..ctor(ApplicationPartManager partManager,IOptions`1 optionsAccessor)--- Fin de la trace de lapileÃpartirde l'emplacementprécé©dent au niveau duquel l'例外aétélevée---

我對此部署感到瘋狂......

解決方案:部署Web應用程序可執行文件的配置文件,該文件包含一些類庫依賴項綁定

一般承認的答案

解決方案是部署Web應用程序可執行文件的配置文件,該文件包含一些類庫依賴項綁定。 .NET的一個老習慣是永遠不要部署.config文件,但顯然需要使用.NET Core來檢查這種做法。

發佈網站時,生成的包中包含一些配置文件,其中一個與應用程序的可執行文件名稱相同,即YourWebsiteNamespace.exe.config。此配置文件包含一些dll綁定,需要與您的應用程序一起部署

此文件可包含的示例:

<configuration>
  <runtime>
    <gcServer enabled="true" />
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="4.0.0.0" newVersion="4.1.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="1.1.37.0" newVersion="1.2.1.0" />
        <bindingRedirect oldVersion="1.2.0.0" newVersion="1.2.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="1.2.0.0" newVersion="1.4.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="4.0.0.0" newVersion="4.1.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="4.0.0.0" newVersion="4.0.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>


Related

許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow