extensions: On Azure AppServices, the following AzureAppServices exception is logged on startup

Describe the bug

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.

To Reproduce

Deploy ASPNET Core 3.0 App to App Services

Expected behavior

Not throw an exception?

Additional context

This has been an upgrade from 2.2, potentially some config is not correct?

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()

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 17 (4 by maintainers)

Most upvoted comments

For folks on this thread, I’m reposting @anurse’s comment on a duplicate thread as a workaround till we fix our site extension


I have a workaround you can try, since all the Site Extension does is configure a special logging component (which is already on NuGet):

  1. Add a package reference to Microsoft.AspNetCore.AzureAppServicesIntegration with the same major-minor version as ASP.NET Core (i.e. 3.0 or 3.1).

  2. Call .UseAzureAppServices on your IWebHostBuilder. If you are using WebHost (i.e. you have a call to WebHost.CreateDefaultBuilder() in your Program.cs, then just add it to that:

WebHost.CreateDefaultBuilder(args)
    .UseAzureAppServices(); // <-- Add this

If you are using generic host (recommended in 3.0+), then this goes in your ConfigureWebHostDefaults call:

Host.CreateDefaultBuilder(args)
    .ConfigureWebHostDefaults(webBuilder =>
    {
        webBuilder.UseStartup<Startup>()
            .UseAzureAppServices(); // <-- Add this
    });


Closing as this should be resolved in 3.1.4 (this is a duplicate of https://github.com/dotnet/aspnetcore/issues/20617).

3.1.4 should be releasing shortly. If that doesn’t resolve the issue, feel free to comment and/or open a new issue!

@satishj80 Your issue is different (despite the similar stack traces, it’s a different hosting startup that’s failing) from the original poster. Do you mind filing a new issue?