Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution for Server Error after DNN upgrade (Microsoft.Extensions.DependencyInjection.Abstractions) #2684

Closed
tvatavuk opened this issue Mar 16, 2022 · 2 comments

Comments

@tvatavuk
Copy link
Contributor

tvatavuk commented Mar 16, 2022

This is a Guide to Fix a Problem after a Dnn Update

Problem

User is doing DNN upgrade to latest DNN 9.10.2 using upgrade zip.
Before upgrade, DNN installation is version 9.10.1 (or older) and it has 2sxc v13+ module installed.
After upgrade, on first run, there is Server Error.

image

Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Extensions.DependencyInjection.Abstractions' could not be loaded.


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace:


[FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

[FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +232
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +113
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +23
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +767
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +256
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +58
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +287
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +69
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +137
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +854

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +724

Cause

  1. DNN 9.4.0+ includes Microsoft.Extensions.DependencyInjection.Abstractions.dll v2.1.1 and Microsoft.Extensions.DependencyInjection.dll v2.1.1 as part of install and upgrade zip.
  2. 2sxc v13+ includes Microsoft.Extensions.DependencyInjection.Abstractions v2.2.0 and Microsoft.Extensions.DependencyInjection v2.2.0 as transient dependency in bin folder.
  3. During dnn upgrade user unzip/copy older version of Microsoft.Extensions.DependencyInjection.Abstractions.dll v2.1.1 and Microsoft.Extensions.DependencyInjection.dll v2.1.1 in DNN bin folder.
  4. On first run ASP.NET notice that binding redirect version of this assemblies in web.config is not the same as version of this dll files in bin folder and throws Server Error.

This is what's added to the web.config, DNN when installing 2sxc (assembly binding redirects)

      <dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" />
        <bindingRedirect oldVersion="0.0.0.0-32767.32767.32767.32767" newVersion="2.2.0.0" />
      </dependentAssembly>
      <dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="Microsoft.Extensions.DependencyInjection" publicKeyToken="adb9793829ddae60" />
        <bindingRedirect oldVersion="0.0.0.0-32767.32767.32767.32767" newVersion="2.2.0.0" />
      </dependentAssembly>

Fix / Current workaround

From https://github.com/2sic/2sxc/releases/download/v13.03.00/2sic_2SexyContent_13.03.00_Install.zip user should unzip and copy dlls v2.2.0 to dnn's bin where are dll's v2.1.1.

  • bin\Microsoft.Extensions.DependencyInjection.Abstractions.dll
  • bin\Microsoft.Extensions.DependencyInjection.dll

image

Than open your DNN web site. Server Error should go away and user can finish DNN upgrade as usual.

image

Additional Information

DNN websites that have 2sxc v13.00-v13.03, after DNN Upgrade to DNN 9.4+ version will get server error Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions' or one of its dependencies.

To prevent this server error please install 2sxc v13.04+ before DNN Upgrade.

With 2sxc v13.04 our goal was to ensure that DNN upgrade do not break DNN installation.

@iJungleboy iJungleboy changed the title After DNN upgrade to latest DNN 9.10.2, server error "Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)" Solution for Server Error after DNN upgrade (Microsoft.Extensions.DependencyInjection.Abstractions) Mar 16, 2022
@iJungleboy iJungleboy pinned this issue Mar 16, 2022
@iJungleboy
Copy link
Contributor

Will mark as closed, as it's pinned to the tasks.

@tvatavuk

This comment was marked as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

2 participants