aspnetcore: HostingStartup failed to execute after updating to .net 7/asp.core 7 on Azure App Service

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

After updating my asp.net core project to .net 7 (all nugets are up to date on the latest 7 releases) I get the following error in the logs on startup

Category: Microsoft.AspNetCore.Hosting.Diagnostics
EventId: 11

Hosting startup assembly exception

Exception: 
System.InvalidOperationException: Startup assembly DiagnosticServices.HostingStartup failed to execute. See the inner exception for more details.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.<InternalLoad>g____PInvoke|47_0(NativeAssemblyNameParts* pAssemblyNameParts, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Int32 throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly)
   at System.Reflection.RuntimeAssembly.InternalLoad(NativeAssemblyNameParts* pAssemblyNameParts, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Boolean throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly)
   at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()
   --- End of inner exception stack trace ---

The startup still continues and the application is responsive afterwards.

Expected Behavior

I expect the hosting startup to not fail on startup.

Steps To Reproduce

No response

Exceptions (if any)

System.InvalidOperationException: Startup assembly DiagnosticServices.HostingStartup failed to execute. See the inner exception for more details. —> System.IO.FileNotFoundException: Could not load file or assembly ‘DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified. File name: ‘DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null’ at System.Reflection.RuntimeAssembly.<InternalLoad>g____PInvoke|47_0(NativeAssemblyNameParts* pAssemblyNameParts, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Int32 throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly) at System.Reflection.RuntimeAssembly.InternalLoad(NativeAssemblyNameParts* pAssemblyNameParts, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Boolean throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly) at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups() — End of inner exception stack trace —

.NET Version

dotnet 7 on AzureAppService

Anything else?

ASP.net core 7 (assemblies involved are Microsoft.AspNetCore.Hosting, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 and System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

@ChristophHornung sorry for the delayed reply. An update to Azure App Service with the fix is currently being rolled out worldwide. Some regions have already been updated. If you have the fix, the environment variable WEBSITE_PLATFORM_VERSION will be 100.0.7.49

@BrennanConroy,

Should this issue be moved […]?

No, I don’t think so. It’s not an App Insights SDK issue. The DiagnosticServices component isn’t open sourced, but we’re tracking this internally.

@ChristophHornung,

Can you or the team elaborate on what the consequences of this issue are?

There are two consequences:

  1. An annoying exception in the startup logs.
  2. The Snapshot Debugger feature is broken.

As you say, the app is otherwise unharmed.

@pharring I am still seeing App Services with WEBSITE_PLATFORM_VERSION on 99.x on my existing and even newly created App Services (in the West Europe and Germany West Central regions). Is there a timeline on when the rollout is complete?

The team is aware of this issue and working on fixing .NET 7 support. cc: @pharring

@pharring Good to know, thank you for the update.

@pharring What is the state of this issue? I am still seeing this error in the logs, shouldn’t this issue be kept open until it is resolved?

@reyang Do you know how this mechanism is supposed to work and whether we need to update anything else for .NET 7?