Error in our ASP.NET Web Host app after updating to the latest version of Visual Studio 2022

Juan-4116 20 Reputation points
2024-12-02T01:40:26.98+00:00

Hi there,

We have an ASP.NET solution running on our dev machines, which are Windows Server 2022 Datacenter. Previously, the app was working fine. However, after updating Visual Studio to the latest version (Microsoft Visual Studio Enterprise 2022 (64-bit)), the app started encountering issues.

  • it is traversal dependency.
  • using the old dependency resolution algorithm helps to fix the issue.
  • VS build is missing the dll, but build with msbuild restore: msbuild -t:restore -p:RestoreUseLegacyDependencyResolver="true" command works all fine and the dll is in the place  

It appears that some DLL files are missing, specifically System.ServiceModel.Http. This missing DLL is causing the following error to appear in the browser: "HTTP Error 500.30 - ASP.NET Core app failed to start."

And getting this error log in Event Viewer:

Application '/LM/W3SVC/2/ROOT/DigitalBankingHost' with physical root 'C:\XXXXX\bin\Debug\net6.0\publish' has exited from Program.Main with exit code = '0'. First 30KB characters of captured stdout and stderr logs:

Environment variable for Bolt encrytion not found. If encryption is enabled, ensure 'BOLT_ENCRYPTION_KEY_HOST' is set.

Host terminated unexpectedly - System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.

Could not load file or assembly 'System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

Could not load file or assembly 'System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)

at System.Reflection.RuntimeAssembly.get_DefinedTypes()

at AutoMapper.ServiceCollectionExtensions.<>c.<AddAutoMapperClasses>b__14_2(Assembly a)

at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToArray()

at AutoMapper.ServiceCollectionExtensions.AddAutoMapperClasses(IServiceCollection services, Action2 configAction, IEnumerable1 assembliesToScan)

at AutoMapper.ServiceCollectionExtensions.AddAutoMapper(IServiceCollection services, Action`2 configAction, Assembly[] assemblies)

at AutoMapper.ServiceCollectionExtensions.AddAutoMapper(IServiceCollection services)

at Retail.API.XXXXXXXX.Startup.ConfigureServices(IServiceCollection services) in C:\XXXXXXXXXXXX\Startup.cs:line 131

at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)

at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)

at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)

at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass15_0.<BuildStartupServicesFilterPipeline>g__RunPipeline|0(IServiceCollection services)

at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)

at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)

at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass14_0.<ConfigureServices>g__ConfigureServicesWithContainerConfiguration|0(IServiceCollection services)

at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)

at Microsoft.AspNetCore.Hosting.WebHost.EnsureApplicationServices()

at Microsoft.AspNetCore.Hosting.WebHost.Initialize()

at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()

at Retail.API.DigitalBankingHost.Program.Main(String[] args) in C:\XXXXXX\Program.cs:line 20

System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

File name: 'System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

File name: 'System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Any help will be appreciated, thanks Juan

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,467 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,181 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
354 questions
Visual Studio Setup
Visual Studio Setup
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Setup: The procedures involved in preparing a software program or application to operate within a computer or mobile device.
1,068 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 31,946 Reputation points Microsoft Vendor
    2024-12-02T07:11:07.55+00:00

    Hello @Juan-4116,

    Thank you for taking time to post this issue in Microsoft Q&A forum.

    Looks like this issue is caused by the VS Update, as nothing was changed except updating VS.

    One method to double confirm this is to roll back VS to the previous version that you were using and was working fine. If this issue disappears, then probably the VS update causes this issue.

    I have checked the release notes of Visual Studio 2022 version 17.12.2 and version 17.12.1. I don’t see any information about the changings for these dll files. I notice that this specific dll file(System.ServiceModel.Http) is included in this NuGet package(System.ServiceModel.Http).

    As the error message says that the version 4.6.0.0 of this dll file was failed to load, please try to install the version 4.6.0 of this NuGet package and rebuild your project, see if the error disappears.

    Please also open the packages.config file in your project(if your project is based on .NET Framework), see if this NuGet package is included correctly, for example <package id="System.ServiceModel.Http" version="4.6.0" targetFramework="netxxx" />. Also, right-click your project, click Unload Project, right-click it again, select Edit Project File to open your project file. See if the dll file is included correctly, for example

    <Reference Include="System.ServiceModel.Http, Version=4.6.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL"
    
     	<HintPath>..\packages\System.ServiceModel.Http.4.6.0\lib\net461\System.ServiceModel.Http.dll</HintPath>
    
    </Reference>
    

    Sometimes, after updating VS, some cache files may cause the error to wrongly prompt. I suggest you also try to clean cache files(rename the bin, obj and the hidden .vs folders) and then rebuild your project.

    However, I do believe that this issue is caused by the update of VS. So, I would suggest you also report this issue to Visual Studio Product Team by clicking Help > Send Feedback > Report a Problem to raise a ticket on our Developer Community and attach the related error/event logs.

    By the way, if installing the NuGet package and removing the cache files don’t work, rolling back or using a previous version of Visual Studio 2022 should be a temporary workaround.

    Best Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.