r7-labs / R7.Dnn.Extensions.EFCore

A library for DNN Platform web CMS extensions development with Entity Framework Core
GNU Lesser General Public License v3.0
4 stars 1 forks source link

Install on clean DNN 9.8.0 errors #2

Open roman-yagodin opened 3 years ago

roman-yagodin commented 3 years ago
Method not found: 'Microsoft.Extensions.DependencyInjection.ServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.
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.MissingMethodException: Method not found: 'Microsoft.Extensions.DependencyInjection.ServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.

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.

Stack Trace:

[MissingMethodException: Method not found: 'Microsoft.Extensions.DependencyInjection.ServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.]
   DotNetNuke.Web.DependencyInjectionInitialize.BuildServiceProvider() +0
   DotNetNuke.Web.Common.Internal.DotNetNukeHttpApplication.Application_Start(Object sender, EventArgs eventArgs) +279

[HttpException (0x80004005): Method not found: 'Microsoft.Extensions.DependencyInjection.ServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +520
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +176
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +165
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +267
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +341

[HttpException (0x80004005): Method not found: 'Microsoft.Extensions.DependencyInjection.ServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +523
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +107
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +688
roman-yagodin commented 3 years ago

DNN 9.8.0 is shipped with Microsoft.Extensions.DependencyInjection assemblies of 2.1.1.0, while R7.Dnn.Extensions.EFCore - with 1.1.0.0 ones.

roman-yagodin commented 3 years ago

Removing Microsoft.Extensions.DependencyInjection.dll and Microsoft.Extensions.DependencyInjection.Abstractions.dll from installer fixes crash after install, but could cause further issues.

roman-yagodin commented 3 years ago

Installing R7.University 2.7.1 after that produces following error. Probably will require binding redirect:

Message:Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.1.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)

StackTrace:

InnerMessage:Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.1.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)

InnerStackTrace:

   at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
   at R7.Dnn.Extensions.EFCore.EFCoreDataContextBase..ctor()
   at R7.Dnn.Extensions.EFCore.EFCoreDnnDataContextBase..ctor()
   at R7.University.Data.UniversityDataContextFactory.Create()
   at R7.Dnn.Extensions.Models.ModelContextBase.get_Context()
   at R7.Dnn.Extensions.Models.ModelContextBase.Query[TEntity]()
   at R7.University.Queries.FlatQuery`1.List()
   at R7.University.Launchpad.DocumentTypesTable.GetDataTable(PortalModuleBase module, UniversityModelContext modelContext, String search)
   at R7.University.Launchpad.LaunchpadTableBase.DataBind(PortalModuleBase module, UniversityModelContext modelContext, String search)
   at R7.University.Launchpad.ViewLaunchpad.BindTab(String tabName)
   at R7.University.Launchpad.ViewLaunchpad.OnLoadComplete(Object sender, EventArgs e)
roman-yagodin commented 3 years ago

After adding binding redirect:

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

Launchpad produces following error:

Message:Method not found: 'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.

StackTrace:

InnerMessage:Method not found: 'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.

InnerStackTrace:

   at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<>c__DisplayClass4_1.<GetOrAdd>b__2(Int64 k)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.EntityFrameworkCore.DbContext.GetServiceProvider(DbContextOptions options)
   at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
   at R7.Dnn.Extensions.EFCore.EFCoreDataContextBase..ctor()
   at R7.Dnn.Extensions.EFCore.EFCoreDnnDataContextBase..ctor()
   at R7.University.Data.UniversityDataContextFactory.Create()
   at R7.Dnn.Extensions.Models.ModelContextBase.get_Context()
   at R7.Dnn.Extensions.Models.ModelContextBase.Query[TEntity]()
   at R7.University.Queries.FlatQuery`1.List()
   at R7.University.Launchpad.DocumentTypesTable.GetDataTable(PortalModuleBase module, UniversityModelContext modelContext, String search)
   at R7.University.Launchpad.LaunchpadTableBase.DataBind(PortalModuleBase module, UniversityModelContext modelContext, String search)
   at R7.University.Launchpad.ViewLaunchpad.BindTab(String tabName)
   at R7.University.Launchpad.ViewLaunchpad.OnLoadComplete(Object sender, EventArgs e)
roman-yagodin commented 3 years ago

Installing 2sxc (e.g. 11.04.00) prior to R7.Dnn.Extensions.EFCore fixes the issue with R7.University due to proper binding redirects and moving required assemblies into bin/2sxc dir. This (plus removing DependencyInjection assemblies) could be considered a quickfix.

Proper solution is to adopt assembly binding code from 2sxc manifest: 2sic_2SexyContent.dnn.txt

In the future releases, this approach could allow to loosen implicit 2sxc relationship.