dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.47k stars 10.03k forks source link

Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute in Azure App service. #48442

Open kapitanmliko opened 1 year ago

kapitanmliko commented 1 year ago

Is there an existing issue for this?

Describe the bug

After updating my asp.net core app to .NET7 I get exception at startup when run in Azure App Service. I have searched and found similar issue here: https://github.com/dotnet/aspnetcore/issues/45022

Issue is closed and seem to be resolved, but mine persists.

Exception at startup:

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 "RuntimeAssembly.cs", line 357, in RuntimeAssembly RuntimeAssembly.InternalLoad(AssemblyName assemblyName, ref StackCrawlMark stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, bool throwOnFileNotFound) File "Assembly.CoreCLR.cs", line 52, in Assembly Assembly.Load(AssemblyName assemblyRef) File "GenericWebHostBuilder.cs", line 147, in void GenericWebHostBuilder.ExecuteHostingStartups()

The server is running without problems but this exception is always there on startup.

Expected Behavior

I would expect no exceptions on application startup.

Steps To Reproduce

No response

Exceptions (if any)

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.

.NET Version

7.0.203

Anything else?

Web App:

Stack settings .NET version: .NET7 (STS) Platform: 64 Bit WEBSITE_PLATFORM_VERSION : 100.0.7.203

Deployment settings:

Target Framework: net7.0 Deployment Mode: Framework-dependant Target Runtime: Portable

easaevik commented 1 year ago

We have the same problem. Azure App Service version 100.0.7.252. Any thoughts on this @pharring ?

ekinskofer commented 1 year ago

Can confirm that this is still happening on Canada Central App Service. Believe the version is 100.0.7.517 according to https://appservice.info/ . We recently upgraded a .net core 3.0 solution to .net 6 and are experiencing this error on startup, though it doesn't impact our application.

bolt-io commented 10 months ago

Also experiencing this on .NET 6 in UK South App Services

rjamiller commented 10 months ago

Also seeing this .Net 8 for UK South. Do not get it when running it from Visual Studio

[2024-01-11 07:53:46 FTL] 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.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 ---

bolt-io commented 10 months ago

I found out that (in my case) the app service had an old version of "ASP.NET Core Logging Integration" in the extensions blade. Updating it to latest (or removing it, as it seems like it's no longer required), solved the issue.

christianAtSuddath commented 9 months ago

I have the same error after updating an API to .Net 8 LTS, hosted in Azure: 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.

christianAtSuddath commented 9 months ago

I found out that (in my case) the app service had an old version of "ASP.NET Core Logging Integration" in the extensions blade. Updating it to latest (or removing it, as it seems like it's no longer required), solved the issue.

Yes! That solved my problem as well! Thank you for posting your solution!

gcsuk commented 7 months ago

I found out that (in my case) the app service had an old version of "ASP.NET Core Logging Integration" in the extensions blade. Updating it to latest (or removing it, as it seems like it's no longer required), solved the issue.

This fixed it for me, thanks very much

hjrb commented 6 months ago

I found out that (in my case) the app service had an old version of "ASP.NET Core Logging Integration" in the extensions blade. Updating it to latest (or removing it, as it seems like it's no longer required), solved the issue.

This fixed it for me, thanks very much

Thank you so much!! Updating did not work for me. But removing the extension did the trick. To bad that MS does not notice themselves that something bad happens. Background services are typically vital for any AppService and typically implement important functionality. In the end the stuff is still not really integrated.

hjrb commented 6 months ago

How can such a bug be open for 1 year?

StandBackBurrito commented 6 months ago

I am seeing the same issue, but I do not have the "ASP.NET Core Logging Integration" extension installed.

sebestyn168 commented 5 months ago

I had the problem 2 months ago and the solution worked for me - and today with a new delivery (with 8.0.5) the problem has come back

vsvsav commented 1 month ago

It helped me to add AspNetCore.AzureAppServices.HostingStartup to the project file. "<[space]PackageReference Include="Microsoft.AspNetCore.AzureAppServices.HostingStartup" Version="8.0.5" /[nospace]>"

[space] - this site is with bug PS I haven't seen this [HostingStartup] error for a long time