Problem with System.Net.Http after upgrade to 7.8.3 and using framework 4.7.2

Hi,

I’ve encountered an issue after upgrading Litium to version 7.8.3.
From what I can see, most of the site is working fine, but there are some issues in BO

The settings menu is empty and there is an error in the console.

The error in the log…

2023-10-17 10:33:16.8386 [App:04] [56b56e91-7611-458b-95ea-2fdfeee83365] [ERROR] [] Litium.IWebLog - IWebLog exception 'Can't create component 'litium.studio.plugins.deployments.ideploymentpackage(litium.accelerator.deployments.acceleratorpackage)' as it has dependencies to be satisfied.

'litium.studio.plugins.deployments.ideploymentpackage(litium.accelerator.deployments.acceleratorpackage)' is waiting for the following dependencies:
- Service 'System.Net.Http.IHttpClientFactory' which was not registered.
': 9d551524-772e-4d5f-a5b1-000f3cdf11bc Castle.MicroKernel.Handlers.HandlerException: Can't create component 'litium.studio.plugins.deployments.ideploymentpackage(litium.accelerator.deployments.acceleratorpackage)' as it has dependencies to be satisfied.

'litium.studio.plugins.deployments.ideploymentpackage(litium.accelerator.deployments.acceleratorpackage)' is waiting for the following dependencies:
- Service 'System.Net.Http.IHttpClientFactory' which was not registered.

   vid Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()
   vid Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
   vid Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
   vid Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, Arguments additionalArguments, IReleasePolicy policy, Boolean ignoreParentContext)
   vid Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.ResolveAll(Type service, Arguments arguments, IReleasePolicy policy)
   vid Castle.Windsor.WindsorContainer.ResolveAll[T]()
   vid Litium.Infrastructure.InversionOfControl.IoCWindsorContainer.ResolveAll[T](Boolean throwException)
   vid Litium.Web.Administration.WebApi.Settings.SettingsMenuProviders.DeploymentSettingsMenuProvider.GetMenuList()
   vid Litium.Web.Administration.WebApi.Settings.Controllers.MenuController.Get()
   vid lambda_method(Closure , Object , Object[] )
   vid System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)
   vid System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__17`1.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
   vid System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   vid System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()

I’ve compared to a clean 7.8.2 accelerator and most things seems to be correct, the entire Litium.Accelerator\Deployments directory has been moved over during the upgrade and references seem to be the same, no build errors or warnings related to this.

Tried Update-Package -ReInstall and that didn’t work, tried clearing the C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files” directory, cleared the bin/obj directories and nothing seems to work.

Some help would be greatly appreciated!

Old Litium version: 7.4.3-patch-2010272019
New Litium version: 7.8.3

Using Microsoft Visual Studio Professional 2022 (64-bit) - Current
Version 17.5.3

Try to remove the complete assemblyBinding from web.config and rebuild the site in Visual Studio, then you will get an information about assembly redirects that missing and you can dbl-click on that to insert the correct assemblyBinding into web.config again.

Also check if you have multiple different references to the System.Net.Http NuGet package. Litium should use version 4.3.4.

You can also try to remove the complete bin-folder to ensure not any old references are left there, IIS/Visual Studio may need to be restarted.

Hi @patric.forsgard,

I double checked the System.Net.Http and 4.3.4 is being used for all the projects that reference System.Net.Http.

I then did the following steps

  1. I removed the entire assemblyBinding from Web.config and Web.Base.config
  2. Rebuilt the site in Visual Sutido and I got the information that you mentioned.
  3. Double-clicked to insert it into Web.config again.
  4. Closed down Visual Studio and killed the w3wp process.
  5. Cleaned the solution, deleted the bin-folder and rebuilt solution again
  6. Still the same error.

Do you have the Litium.Web.Setup.Elasticsearch package included in your solution?

If you add the following code inside the Litium.Accelerator project, will it work?

using Litium.Runtime;
using Microsoft.Extensions.DependencyInjection;

namespace Litium.Accelerator.Runtime
{
    public class Bootstrapper : IApplicationConfiguration
    {
        public void Configure(ApplicationConfigurationBuilder app)
        {
            app.ConfigureServices(services =>
            {
                services.AddHttpClient();
            });
        }
    }
}
3 Likes

I can not find any references to Litium.Web.Setup.Elasticsearch anywhere, Litium.Web.Setup.Complete, Litium.Web.Setup.Core and Litium.Web.Setup.Mvc are included/installed.

I do not have that Bootstrapper class, is that required in general or is that just for Elasticsearch? From what I can see it is not included in a clean 7.8.2 accelerator.

I tried to add it and that solved the issue, thanks!

// JT

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.