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.
Deploy ASPNET Core 3.0 App to App Services
Not throw an exception?
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()
@ctolkien Is your application self contained?
@davidfowl - nope.
Could it be due to files being left over from the previous 2.2?
(Not sure if deployments remove all old files)
There's a known issue where this site extension wasn't updated for 3.0. @anurse
Edit: nevermind, there is a 3.0 version of this package. https://www.nuget.org/packages/Microsoft.AspNetCore.AzureAppServices.HostingStartup/3.0.0
Honestly its likely our bug. The site extension is enabled by default when you deploy from visual studio. You can disable it on the app service side. Another option would be to add the package reference to your project directly.
Looks like a similar problem as https://github.com/aspnet/AspNetCore/issues/16604
The site extension may be messed up.
Honestly its likely our bug. The site extension is enabled by default when you deploy from visual studio. You can disable it on the app service side. Another option would be to add the package reference to your project directly.
I added to .csproj:
< PackageReference Include = "Microsoft.AspNetCore.AzureAppServices.HostingStartup" Version = "3.1.1" />
And yet I still have the same exception.
Any update on this? I am hitting the same issue on .net core 3.0.
System.InvalidOperationException: Startup assembly Microsoft.ApplicationInsights.StartupBootstrapper failed to execute. See the inner exception for more details.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ApplicationInsights.StartupBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.ApplicationInsights.StartupBootstrapper, 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()
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.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()
@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?
I upgraded from aspnetcore 2.2 to 3.1 and seeing the same error
i.e.
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.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
@anurse @BrennanConroy Looks like this is still broken. I just cracked open the package and we're missing both 3.0 and 3.1 bits in the site extension

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):
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).
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
});
This is https://github.com/dotnet/aspnetcore/issues/20617 which should be fixed in 3.1.4
The workaround solved my issue.
I tried the above work around, but still getting the error. Works fine in a local environment.
"System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details.\r\n ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.\r\nFile name: 'Microsoft.AspNetCore.AzureAppServices.HostingStartup, Culture=neutral, PublicKeyToken=null'\r\n at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly assemblyContext, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)\r\n at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)\r\n at System.Reflection.Assembly.Load(AssemblyName assemblyRef, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)\r\n at System.Reflection.Assembly.Load(AssemblyName assemblyRef)\r\n at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ExecuteHostingStartups()\r\n\r\n\r\n --- End of inner exception stack trace ---"
@johndcollins for me I think it also didnt on the first try.
I needed to change to WebHost.CreateDefaultBuilder (before I used a more custom setup).
I also added <PackageReference Include="Microsoft.AspNetCore.AzureAppServices.HostingStartup" Version="3.1.1" /> once and deployed. However I removed it again, so I think it is not necessary.
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!
~Using 3.1.4 I still see this issue.~
Sorry nvm, I have hit another issue and the logs confused me. App works on 3.1.4 without including HostingStartup explicitly.
Most helpful comment
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):
Add a package reference to
Microsoft.AspNetCore.AzureAppServicesIntegrationwith the same major-minor version as ASP.NET Core (i.e. 3.0 or 3.1).Call
.UseAzureAppServiceson yourIWebHostBuilder. If you are using WebHost (i.e. you have a call toWebHost.CreateDefaultBuilder()in yourProgram.cs, then just add it to that:If you are using generic host (recommended in 3.0+), then this goes in your
ConfigureWebHostDefaultscall: