Deployment ASP.NET Core 1.1.0 & Entity Framework Core 1.1 : Unable to load assembly system.Collections.Immutable, Version=1.1.37.0

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

Question

I migrated my project to ASP.NET Core 1.1.0 and Entity Framework Core 1.1, and all is working fine in develoment.

But impossible to deploy the project in staging, I have this error from stdout logs :

Application startup exception: 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 ses d‚pendances. La d‚finition trouv‚e du manifeste de l'assembly ne correspond pas … la r‚f‚rence de l'assembly. (Exception de HRESULT : 0x80131040) Nom de fichierÿ: 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
… Agata.Presentation.Web.Startup.ConfigureServices(IServiceCollection services) --- Fin de la trace de la pile … partir de l'emplacement pr‚c‚dent au niveau duquel l'exception a ‚t‚ lev‚e --- … System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() … Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) … Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() … Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

I checked all the nuget packages from all the projects contained in the solution and all the dependencies are up to date.

I've deleted all the staging's directory and redeploy it completely to be sure there is no old dlls but the error is still here. I also restart the IIS pool and the website, several times.

And .NET Core 1.1.0 is installed on the server.

Anyone has an idea on what's going on here ?

EDIT : this is my 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"
  },

EDIT: The problem is different now, the error now is :

Application startup exception: 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 ses d‚pendances. La d‚finition trouv‚e du manifeste de l'assembly ne correspond pas … la r‚f‚rence de l'assembly. (Exception de HRESULT : 0x80131040) Nom de fichierÿ: '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 la pile … partir de l'emplacement pr‚c‚dent au niveau duquel l'exception a ‚t‚ lev‚e --- … System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() … Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) … Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() … Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

This is my updated 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"
  },

The line 65 of my startup file is :

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

It's still working fine in debug with visual studio ...

EDIT 2 : I resolved the System.Interactive.Async updating the Serilog.Extensions.Logging package... I have now the error :

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 de ses dépendances. La définition trouvée du manifeste de l'assembly ne correspond pas à la référence de 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 la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---

I'm just going crazy with this deployment ...

SOLUTION : deploy the web application executable's configuration file, who contains some class library dependency bindings

1
2
11/22/2016 1:55:47 PM

Accepted Answer

The solution was to deploy the web application executable's configuration file, who contains some class library dependency bindings. An old practice with .NET is to never deploy a .config file but this practice obviously needs to be reviewed with .NET Core.

When you publish your website, the package generated contains some config file, one of them has the same name as your application's executable, YourWebsiteNamespace.exe.config. This configuration file contains some dll bindings and needs to be deployed with your application

Example of what this file can contain :

<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>
3
11/21/2016 8:31:55 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow