aspnetcore: Microsoft.AspNetCore.Hosting throws Startup assembly StartupBootstrapper failed to execute

I see these errors logged on Azure (App Service) on every restart of the App Service:

Main message:

Startup assembly StartupBootstrapper failed to execute. See the inner exception for more details. Could not load file or assembly 'StartupBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. 

Stack trace:

System.InvalidOperationException:
System.IO.FileNotFoundException:
   at System.Reflection.RuntimeAssembly.nLoad (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Reflection.Assembly.Load (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Reflection.Assembly.Load (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups (Microsoft.AspNetCore.Hosting, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)

Let me know what additional data I can collect for you that may help in fixing this issue.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 22
  • Comments: 58 (31 by maintainers)

Most upvoted comments

Note, this is reproducible in Core 3.1.

I have fixed the

"Startup assembly StartupBootstrapper failed to execute. See the inner exception for more details. Could not load file or assembly ‘StartupBootstrapper, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified. "

by uninstalling the Azure web app AI site extension as suggested here.

I have also fixed the

"Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details. Could not load file or assembly ‘Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified. "

by installing "<PackageReference Include="Microsoft.AspNetCore.AzureAppServices.HostingStartup" Version="3.1.0" />"

Also applied the advice from https://github.com/dotnet/aspnetcore/issues/15381#issuecomment-566777363 but not sure if it helped.

Now the only issue i get is

"Startup assembly DiagnosticServices.HostingStartup failed to execute. See the inner exception for more details. Could not load file or assembly ‘DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified. "

which i can only fix by following the advice from https://github.com/dotnet/aspnetcore/issues/17370#issuecomment-567543883 which disables the profile and snapshot feature.

Is it possible to have profile and snapshot features working without getting the " DiagnosticServices.HostingStartup failed to execute" exception message?

I’m using framework dependant deployment from within visual studio publish screen and the app is .net core 3.1.0 64bit

Aaand we resolved the other error (see below) by once again disabling another portal-enabled extension. This time it was the Application Insights that was actually enabled on ANOTHER slot (a .net fw 4.6.1 app) of the same web app service.

image

To be honest, these portal injected ‘magic’ extensions have rather painful in our experience. They don’t feel production-ready (all the tickets), hurt testability (behavior changes post-testing), aren’t well documented (like which env variables are injected from which extension? cleanup?).

error ``` 2020-01-04 18:50:51.436 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics: Hosting startup assembly 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. ```

I’m facing the same issue after upgrading our web app from 2.1 to 3.0. However, it is not self-contained. Shall I open a new issue for that case?

We were able to eliminate the error (see error below) around Microsoft.AspNetCore.AzureAppServices.HostingStartup by uninstalling the site extension ASP.NET Core Logging Integration. It’s a trap because the Azure portal presents this large nag button

DO NOT CLICK THAT NAG 👇

image

If you accidentally click on that nag, it’ll install the extension without any confirmation and the errors with return.

@davidfowl : Does this add up in your view? Is there a better recommendation for this fix?

error
2020-01-04 00:05:56.902 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics:
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()

OK I spent some time looking into this and you can’t get rid of this exception today if the application is self contained. The feature being used to inject application insights into the application always fails on startup (because of a limitation in the current design).

The only way to get rid of it today is to do a framework dependent deployment by either waiting for 3.0 to be installed on app service or by using the ASP.NET Core runtime site extension.

I’ll keep this issue open and assign it to myself as it’s something we need to solve.

We also get this exception on every startup of our Azure app service.

I just upgraded .NET 5.0 and it is still happening.

What is the latest/recommended way of getting rid of this message. Are we really forced to install Microsoft.AspNetCore.AzureAppServices.HostingStartup to get rid of it?

(We currently don’t use Application Insights)

I have fixed the

"Startup assembly StartupBootstrapper failed to execute. See the inner exception for more details. Could not load file or assembly ‘StartupBootstrapper, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified. "

by uninstalling the Azure web app AI site extension as suggested here.

I have also fixed the

"Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details. Could not load file or assembly ‘Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified. "

by installing "<PackageReference Include="Microsoft.AspNetCore.AzureAppServices.HostingStartup" Version="3.1.0" />"

Also applied the advice from #15381 (comment) but not sure if it helped.

Now the only issue i get is

"Startup assembly DiagnosticServices.HostingStartup failed to execute. See the inner exception for more details. Could not load file or assembly ‘DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null’. The system cannot find the file specified. "

which i can only fix by following the advice from #17370 (comment) which disables the profile and snapshot feature.

Is it possible to have profile and snapshot features working without getting the " DiagnosticServices.HostingStartup failed to execute" exception message?

I’m using framework dependent deployment from within visual studio publish screen and the app is .net core 3.1.0 64bit

I also had this mysterious “azure app svc Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute” exception logged in App Insights, from Asp Net Core 2.1 on Windows, and was not able to make it go away with Self-Contained or Framework-Dependent. All the App Insights logging and TelemetryClient seemed to be working. Errors are automatically logged from Controller Constructors, and even from exceptions during Startup. But seeing this Exception is innerving.

I found this issue and suggestion to install this package … I can confirm that installing NuGet package Microsoft.AspNetCore.AzureAppServices.HostingStartup stopped the logged entries.

@SidShetye The site extension enables the logging options in the azure portal for azure app service to work. The HostingStartup is a way to plug into the application startup process without that code having be in the application initially. Think of it as a plugin. There’s a plugin that runs on app service to enable app service features. When it breaks it’s because there’s a version mismatch, that is, there’s a newer version of .NET Core than the extension supports (this is what we’re working on moving forward, extensions are tied to the .NET Core major minor version).

You can enable the same feature by adding the package reference directly and calling the registration API (this is what the plugin package does) and why things work if you reference the package directly.

Alternative you can enable rawWrite="true" for the Trace-Target (Skips LogLevel mapping but always uses Trace.WriteLine)

<target xsi:type="Trace" name="trace" layout="${logger} ${message} ${exception:format=tostring}" rawWrite="True" />

We’re seeing this issue on Azure App Service Windows Servers + .NET Core 3.1 + FDD (not SCD as above). The same app deployed to Azure App Service Linux Containers + .NET Core 3.1 + FDD does not have this issue. There is also another immediate log entry related to Microsoft.AspNetCore.AzureAppServices.HostingStartup, copying that here too for SEO and other folks hitting this issue.

What’s the timeline to resolution? It’s holding up our production migration to 3.1 since it’s LTS.

------------------------------
2019-12-12 23:31:06.885 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics:
Hosting startup assembly 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.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()


   --- End of inner exception stack trace ---
------------------------------
2019-12-12 23:31:07.897 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics:
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()


   --- End of inner exception stack trace ---

@SidShetye I said it 11 days ago but nobody seemed to notice.

@davidfowl , yup that worked - thanks again. Have yourself a happy new decade!

Any update or issue tracking this @davidfowl ? Can you loop me in on conversations related to this?