Aspnetcore: Startup assembly StartupBootstrapper failed to execute

Created on 24 Apr 2018  路  75Comments  路  Source: dotnet/aspnetcore

Im getting this error in my logs currently:

2018-04-23 18:10:25.818 +00:00 [Fatal] Hosting startup assembly exception
System.InvalidOperationException: Startup assembly StartupBootstrapper failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'StartupBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, IntPtr ptrLoadContextBinder)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
--- End of inner exception stack trace ---

Im using the following version of microsoft.aspnetcore:
.nugetpackagesmicrosoft.aspnetcore2.0.1libnetstandard2.0Microsoft.AspNetCore.dll

Am i missing something or is this a known bug? Im hosting this in an Azure App Service.

area-hosting

Most helpful comment

We are running an Azure Web App that we recently upgraded to .net Core 2.1 with Microsoft.ApplicationInsights.AspNetCore 2.3.0.

We are also getting this exception:

Hosting startup assembly exception System.InvalidOperationException: Startup assembly StartupBootstrapper failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'StartupBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) --- End of inner exception stack trace --

All 75 comments

We're going to need more than that, Can you share a repro app?

Any call to Assembly.Load is suspect. What are you trying to do?

Creating a repro app will take some time as this is (company) production code, but in essentially we're just doing this:

`public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .Build();
}`

Which in turn executes this:

            `// Execute the hosting startup assemblies
            foreach (var assemblyName in _options.GetFinalHostingStartupAssemblies().Distinct(StringComparer.OrdinalIgnoreCase))
            {
                try
                {
                    var assembly = Assembly.Load(new AssemblyName(assemblyName));

                    foreach (var attribute in assembly.GetCustomAttributes<HostingStartupAttribute>())
                    {
                        var hostingStartup = (IHostingStartup)Activator.CreateInstance(attribute.HostingStartupType);
                        hostingStartup.Configure(this);
                    }
                }
                catch (Exception ex)
                {
                    // Capture any errors that happen during startup
                    exceptions.Add(new InvalidOperationException($"Startup assembly {assemblyName} failed to execute. See the inner exception for more details.", ex));
                }
            }`

Im not sure where this StartupBootstrapper is coming from. Could you give me a hint to be able to look this up?

To be honest i think it's related to https://github.com/aspnet/Hosting/issues/1246

I added this reference to my project a while ago:

<PackageReference Include="Microsoft.AspNetCore.AzureKeyVault.HostingStartup" Version="2.0.2-preview2-final" />

Before that i noticed the same error, but it mentioned the Azure Key Vault dll could not be found.

@pakrym

I understand you are busy, but i havent had an answer in a week. Any updates?

Do you have any site extensions installed? ApplicationInsighths? What version?

We got the same exception in our app. After removing the ApplicationInsights site extension from the deployment script, the exception vanished. Any idea how to fix this?

@clguimanMSFT any ideas?

StartupBootstrapper comes from the "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" environment variable which is set by the ApplicationInsights site extension.
Is the code running on netcore 2.0 or 2.1?
If it's 2.0 please share the content of the following env variables:
DOTNET_SHARED_STORE & DOTNET_ADDITIONAL_DEPS

@clguimanMSFT
We use asp net core 2.0 with .net framework:

    <TargetFramework>net461</TargetFramework>
    <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
    <Platforms>AnyCPU;x64</Platforms>

The only DOTNET_... environment variables, that Kudu shows are:
DOTNET_CLI_TELEMETRY_PROFILE = AzureKudu
DOTNET_HOSTING_OPTIMIZATION_CACHE = D:DotNetCache
DOTNET_SKIP_FIRST_TIME_EXPERIENCE = true
Also it doesnt show ASPNETCORE_HOSTINGSTARTUPASSEMBLIES.

Did you get this variables from Process Explorer => dotnet process?
Did you restart your application after installing the ApplicationInsights extension?

@clguimanMSFT I got it from Environment -> environment variables. I didn't know that these are different from the ones under Process Explorer.

In Process Explorer I have these:

  • w3wp.exe:
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES | StartupBootstrapper
DOTNET_ADDITIONAL_DEPS | D:\Program  Files  (x86)\dotnet\additionalDeps\Microsoft.AspNetCore.ApplicationInsights.HostingStartup\;D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\2.5.6\core\additionalDeps
DOTNET_SHARED_STORE | D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\2.5.6\core\store\
  • SnapshotHolder_x86.exe:
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES | StartupBootstrapper
DOTNET_ADDITIONAL_DEPS | D:\Program  Files  (x86)\dotnet\additionalDeps\Microsoft.AspNetCore.ApplicationInsights.HostingStartup\;D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\2.5.6\core\additionalDeps
DOTNET_SHARED_STORE | D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\2.5.6\core\store\
  • My Api exe without any environment variables

Edit: Yes, I did restart the application afterwards.

@saithis You deployed a self-contained dotnetcore application? We don't support auto enablement of ApplicationInsights & SnapshotCollector for those. You'll need to add these packages as nuget dependencies to your project.

You can find more information here:

@clguimanMSFT Yes, it is a self-contained aspnetcore application running on .net framework 4.6.1. We have installed the Microsoft.ApplicationInsights.AspNetCore as a nuget package, but also installed the site extension to get the sql queries in the logs.

I will try installing the snapshot debugger nuget package when I get back to work on monday, thanks.

You can still install the extension, but your app shouldn't try and blindly load HostingStartup assemblies. If there's some reason you need to do that, you can just ignore the exception for StartupBootstrapper or explicitly remove that assembly from the list

@clguimanMSFT Its the asp net core code that "blindly loads HostingStartup assemblies" in WebHostBuilder.Build(). But setting "hostingStartupExcludeAssemblies" to "StartupBootstrapper" should exclude that assembly then, right? Can you tell me what the StartupBootstrapper assembly is for? Is there a negative effect for self-contained aspnetcore applications, when it can't be loaded and I just exclude it?

Thanks for the help so far :)

The StartupBootstrapper assembly is part of ApplicationInsights site extension and it's used to inject ApplicationInsights assemblies in Azure Web Apps. This code detects if ApplicationInsights is already present in the process and will back-off if necessary.
@pakrym can you please help @saithis with the HostingStartup questions?

@clguimanMSFT We are using Azure App Services and run the same configuration as @saithis. We are using .net core 2.0 and application insights 2.4.0 and get the same exception in our logs.

Under process i couldnt find anything other then w3wp.
What is the next step to resolve this problem?

I tried the hostingStartupExcludeAssemblies setting now and it didn't work. I'm still getting the exception :/

@isualize Are you deploying a self-contained application? If so - please follow the instructions here: https://github.com/aspnet/Hosting/issues/1398#issuecomment-387842930

@clguimanMSFT ill give that a try and will get back to you

@clguimanMSFT thanks for your help. I installed Microsoft.ApplicationInsights.AspNetCore 2.2.1 and the problem went away. What's the reason we need to install this seperately?

@isualize were you deploying a self-contained application? Previously you were getting the same exception with 'StartupBootstrapper not found'?

I have a pretty basic .NET Core 2.0 web app deployed as an Azure App Service. I did a deployment today which had no changes compared to a working version that has been online and working for months and suddenly I got

System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureKeyVault.HostingStartup failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.AzureKeyVault.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, IntPtr ptrLoadContextBinder)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
   --- End of inner exception stack trace ---

It doesn't use/reference AzureKeyVault.

@clguimanMSFT yes we deployed into an Azure App Service container. We did not get this exception at all using IIS on a virtual machine at our other hosting party.

I think you got 2.1-preview1 of AppServices site extension installed. You can safely ignore this exception, it would go away with next site extension release.

@pakrym Im getting emails if the amount of http error in the last hour are greater than x in Azure. I'd like to know when theyre serious or not. There is a chance i might overlook other errors when i keep facing this issue.

We are running an Azure Web App that we recently upgraded to .net Core 2.1 with Microsoft.ApplicationInsights.AspNetCore 2.3.0.

We are also getting this exception:

Hosting startup assembly exception System.InvalidOperationException: Startup assembly StartupBootstrapper failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'StartupBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) --- End of inner exception stack trace --

@vmendi The ApplicationInsights site extension is not currently supporting ASP.NET Core 2.1 applications. We'll have a release as soon as possible.
The exception you're seeing is not fatal, and you can ignore it in the meantime.
I'll let you know once the new version of the extension is released

@vmendi Application Insights extension for Azure App Service 2.6.3 was released - this version supports ASP.NET Core 2.1. Please upgrade to this version

Dumb question @clguimanMSFT - but how do we "upgrade to version 2.6.3" ? Also, how can I confirm what my _existing_ site-extension version is?

Context: I'm having the _exact_ same exception as @vmendi .

@PureKrome go to http://.scm.azurewebsites.net/ApplicationInsights to see the current extension version.
To upgrade you can do one of the following:

  1. From the App Service blade in the Azure Portal click on "Application Insights" (on the left, mid screen) and you'll get a banner asking you to upgrade if required.
  2. Go to Kudu (from the App Service blade click on "Advanced Toold" on the left) , click on "Site extensions" and you'll see the "Application Insights extension for Azure App Service" which requires an update. After updating click "Restart Site" to restart Kudu and then also restart the App Service to enable the extension for you web app.

Thanks @clguimanMSFT ! My extension wasn't v 2.6.3 and it did have the upgrade option there :) Upgraded, error went away. Awesome and thanks!

Oh! question .. Do I still need this AI Extension if I've got AppInsights code in my aspnetcore 2.1 web app? Do I need both?

The site extension also enables some extra features like Snapshot Debugger and Application Insights Profiler.
If you want to use these features you'll have to make sure they are enabled. If you installed the site extension through the Application Insights page from the Azure App Service page then you'll have them on by default. If you installed the site extension separately or it has be installed some time ago (before May 2018) you should make sure the Application Insights enablement is properly set so you'll need to go to the Application Insights blade (left side, mid screen) and click "Change": there you can select the same resource you've already used and afterwards you'll need to pick the Runtime and expand Advanced Settings to pick the right options for you.
image
After you click "OK" you'll have to scroll up and click "Continue"

If you don't want to use the ApplicationInsights blade you can enable the feature by adding these Application Settings in the portal: APPINSIGHTS_PROFILERFEATURE_VERSION = 1.0.0 (for profiler) , APPINSIGHTS_SNAPSHOTFEATURE_VERSION = 1.0.0 (for snapshot debugger).

I have the same issue. I have asp.net core 2.1 and I have configured app insights (I see everything in app inights). Then I wanted to use the profiler and conntected the app with steps above to app insights. I can see in the profiler in app insights that the app is connected, but I don't see any profiler telemetry data which I would expect. Also profile now is not working. When I check the log files I see following issue:

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.
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)

As mentioned here: https://github.com/aspnet/Hosting/issues/1398#issuecomment-387886627

The StartupBootstrapper assembly is part of ApplicationInsights site extension and it's used to inject ApplicationInsights assemblies in Azure Web Apps. This code detects if ApplicationInsights is already present in the process and will back-off if necessary.

I spent some time to figure it out.

I got this exception when I was using the extension from Azure together with code reference to ApplicationInsights.

I ended-up removing the extension form Azure and leaving only my project's references to AI:

  .UseApplicationInsights()

This way, exception was gone.

I get this exception, too. It happens when I go to the Performance tab in App Insights, click on the "Profiler" button, then click "Install".
In my case, the app completely stops working at this point.
Then I have to go to http://.scm.azurewebsites.net/ApplicationInsights and click "disable" on the Profiler Web Job, but I can leave the other two enabled.

I also have a self contained Asp.Net core 2.1 app. However, I want the App Insight Profiler enabled to measure performance. How do I enable this without bringing my site down?

@joshmouch is there any official documentation on that button? The two official docs I could find are either outdated (https://docs.microsoft.com/en-us/azure/application-insights/app-insights-profiler) or the feature is not currently working on Azure (https://blogs.msdn.microsoft.com/appserviceteam/2018/06/06/app-service-diagnostics-profiling-an-asp-net-web-app-on-azure-app-service/).

Despite the lack of docs, I clicked that button you mentioned and the subsequent "Profile Now" button anyway. But after a few minutes of "The profiling session is in progress", nothing appears to have happened.

The number of seemingly redundant features accompanied by incomplete and outdated documentation is infuriating.

@jbaumbach This is working for me now after uninstalling from every one of my app services (including slots on the app service), then updating ASP.Net Core extensions to the latest, and then installing the Profiler again. Somewhere in there, I went in and deleted a bunch of extra folders that were lying around that still had config files in them. That may have been what fixed it... not sure.

However, I have yet to do another slot swap since it started working, and I think this is originally where the trouble started happening.

@joshmouch Thanks for the info. We got it working too, now the tough part is finding out why we have so many BLOCKED_TIME entries.

I'm having the same issue. My app is ASP.NET Core 2.1 using the full .net framework (4.7). Reinstalled everything and using the latest version. Still failing.

Hi, does anyone know how to remove the application insight extension? Should I just remove the directory from azure ?

@alincosmin7 You can remove the site extension by going to the "Extensions" blade under "Development Tools" in the App Service page.

Today we are rolling out a new enablement experience that doesn't require a site extension and fixes some of the existing issues. If you want to try that out you can click on the "Application Insights" link in the "Settings" section and then, from the blade, click on "Turn on site extension". This will remove the old extension and enable the built-in Application Insights enablement.
image
@halkor sorry for the late reply. Can you please try the new enablement experience at explained above?

Hey @clguimanMSFT , I enabled the new Application Insights experience in my App as you said, however, I still get the same error:

Message: Hosting startup assembly exception Could not load file or assembly 'StartupBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
Exception: System.InvalidOperationException: Startup assembly StartupBootstrapper failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'StartupBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) --- End of inner exception stack trace

@marcusvnac what version of .NET Core are you targeting? Is it a self-contained dotnetcore application?
Please share the values of the following environment variables (From Kudu->Process explorer-> Properties on the 'dotnet.exe' process):
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES, DOTNET_ADDITIONAL_DEPS, DOTNET_SHARED_STORE

@clguimanMSFT It is a self-contained dotnetcore app. The target FW is netcoreapp2.1.

ASPNETCORE_HOSTINGSTARTUPASSEMBLIES:
StartupBootstrapper;DiagnosticServices.HostingStartup;StartupBootstrapper;Microsoft.AspNetCore.AzureAppServices.HostingStartup;Microsoft.AspNetCore.Server.IISIntegration

DOTNET_ADDITIONAL_DEPS: D:Program Files (x86)dotnetadditionalDepsMicrosoft.AspNetCore.ApplicationInsights.HostingStartup;D:Program Files (x86)SiteExtensionsApplicationInsightsAgent2.6.8coreadditionalDeps;D:Program Files (x86)SiteExtensionsDiagnosticServices3.0.2coreadditionalDeps;D:Program Files (x86)dotnetadditionalDepsMicrosoft.AspNetCore.ApplicationInsights.HostingStartup;D:homeSiteExtensionsMicrosoft.ApplicationInsights.AzureWebSites2.6.5coreadditionalDeps;D:homeSiteExtensionsMicrosoft.AspNetCore.AzureAppServices.SiteExtensionadditionalDepsMicrosoft.AspNetCore.AzureAppServices.HostingStartup;D:Program FilesdotnetadditionalDepsMicrosoft.AspNetCore.AzureAppServices.HostingStartup

DOTNET_SHARED_STORE: D:Program Files (x86)SiteExtensionsApplicationInsightsAgent2.6.8corestore;D:Program Files (x86)SiteExtensionsDiagnosticServices3.0.2corestore;D:homeSiteExtensionsMicrosoft.ApplicationInsights.AzureWebSites2.6.5corestore;D:homeSiteExtensionsMicrosoft.AspNetCore.AzureAppServices.SiteExtensionstore

We dont' support self-hosted dotnetcore application. Please read this for possible options: https://github.com/aspnet/Hosting/issues/1398#issuecomment-387842930

I have those too. So I just have to disable this App Insights in my App in Azure and I am good to go?

Yes, but that will also disable Service Profiler.
If you still want to use ServiceProfiler I recommend keeping ApplicationInsights enabled in the Azure App Service, but updating the following App Setting: "ApplicationInsightsAgent_EXTENSION_VERSION=disabled". This will disable the SDK injection (the one causing the exception), but it will keep SnapshotCollector injection and ServiceProfiler webjob.

I updated the settings, however, I still get the same error. Here is how is set up now:

image

image

Please share ASPNETCORE_HOSTINGSTARTUPASSEMBLIES, DOTNET_ADDITIONAL_DEPS, DOTNET_SHARED_STORE again.
Just to double check: After updating the App Setting and saving the change, you didn't click on "Turn on site extension" again, right?

No, I didn't click to re-enable it.

ASPNETCORE_HOSTINGSTARTUPASSEMBLIES: DiagnosticServices.HostingStartup;Microsoft.AspNetCore.AzureAppServices.HostingStartup;Microsoft.AspNetCore.Server.IISIntegration --

DOTNET_ADDITIONAL_DEPS: D:\Program Files (x86)\SiteExtensions\DiagnosticServices\3.0.2\core\additionalDeps;D:\home\SiteExtensions\Microsoft.AspNetCore.AzureAppServices.SiteExtension\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;D:\Program Files\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\ --

DOTNET_SHARED_STORE: D:\Program Files (x86)\SiteExtensions\DiagnosticServices\3.0.2\core\store\;D:\home\SiteExtensions\Microsoft.AspNetCore.AzureAppServices.SiteExtension\store --

Sorry, the trick I described doesn't work. You're exception is actually different now, probably it's failing to load "DiagnosticServices.HostingStartup" or "Microsoft.AspNetCore.AzureAppServices.HostingStartup".
Currently there's no way of enabling the ServiceProfiler webjob without getting those exceptions. By the way -those are not fatal exceptions, right? They just create noise.
I recommend disabling the Application Insights extension by turning it on and then off again, just so the App settings are properly set.

Np. I did what you said and I still get the error: Hosting startup assembly exception Could not load file or assembly 'DiagnosticServices.HostingStartup, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified..

As you said, this is just noise, no fatal exception. By the end, I should leave the AppInsights disabled in the Azure Web App and get it working just by adding the Nuget packages and the startup code to my application, correct?

You get "DiagnosticServices.HostingStartup" in the exception after clicking on "Turn on site extension", clicking "Save", then turning it off and clicking "Save" again?

When the extension is completely off "DiagnosticServices.HostingStartup" shouldn't be in ASPNETCORE_HOSTINGSTARTUPASSEMBLIES. The only ones left should be "Microsoft.AspNetCore.AzureAppServices.HostingStartup;Microsoft.AspNetCore.Server.IISIntegration" which are controlled by other private site extensions, which you can uninstall from the "Extensions" blade.

Yes, I recommend using the Nuget packages in your self-hosted scenario.

Yes, I did that. Enabled and disabled it. I am still getting it after having it disabled and after restarting my app. I checked the ASPNETCORE_HOSTINGSTARTUPASSEMBLIES and DiagnosticServices.HostingStartup is still there. Maybe there is some problem setting the environment variable. I have three different Azure Web Apps, in different subscriptions. I did that to all of them and got the same result.

I will use just the Nuget packages approach. Thank you.

You also have to manually set all the options in "Instrument your application" to Off.

Oh yeah, this did the trick! Thank you.

@clguimanMSFT
I'm still getting the "Startup assembly StartupBootstrapper failed to execute." error. I disabled the Application Insights Site extension and disabled all of the options underneath it. The odd thing is that I get this exception after my EXE has loaded and has been configured in the w3wp.exe process. Here are the environment variables:

w3wp.exe:
    ASPNETCORE_HOSTINGSTARTUPASSEMBLIES StartupBootstrapper;Microsoft.AspNetCore.AzureAppServices.HostingStartup

    DOTNET_ADDITIONAL_DEPS  D:\Program Files (x86)\dotnet\additionalDeps\Microsoft.AspNetCore.ApplicationInsights.HostingStartup\;D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\2.6.5\core\additionalDeps;D:\home\SiteExtensions\Microsoft.AspNetCore.AzureAppServices.SiteExtension\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;D:\Program Files\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\

    DOTNET_SHARED_STORE D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\2.6.5\core\store\;D:\home\SiteExtensions\Microsoft.AspNetCore.AzureAppServices.SiteExtension\store


    SnapshotHolder_x64.exe
        ASPNETCORE_HOSTINGSTARTUPASSEMBLIES StartupBootstrapper;Microsoft.AspNetCore.AzureAppServices.HostingStartup

        DOTNET_ADDITIONAL_DEPS  D:\Program Files (x86)\dotnet\additionalDeps\Microsoft.AspNetCore.ApplicationInsights.HostingStartup\;D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\2.6.5\core\additionalDeps;D:\home\SiteExtensions\Microsoft.AspNetCore.AzureAppServices.SiteExtension\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;D:\Program Files\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\

        DOTNET_SHARED_STORE D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\2.6.5\core\store\;D:\home\SiteExtensions\Microsoft.AspNetCore.AzureAppServices.SiteExtension\store

    MyApi.exe

        ASPNETCORE_HOSTINGSTARTUPASSEMBLIES StartupBootstrapper;Microsoft.AspNetCore.AzureAppServices.HostingStartup;Microsoft.AspNetCore.Server.IISIntegration

        DOTNET_ADDITIONAL_DEPS  D:\Program Files (x86)\dotnet\additionalDeps\Microsoft.AspNetCore.ApplicationInsights.HostingStartup\;D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\2.6.5\core\additionalDeps;D:\home\SiteExtensions\Microsoft.AspNetCore.AzureAppServices.SiteExtension\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;D:\Program Files\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\

        DOTNET_SHARED_STORE D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\2.6.5\core\store\;D:\home\SiteExtensions\Microsoft.AspNetCore.AzureAppServices.SiteExtension\store

D:homeSiteExtensionsMicrosoft.ApplicationInsights.AzureWebSites2.6.5...

It seems the new enablement page didn't remove the old extension. Probably because you didn't first enable the extension, click "Apply", then disable all the features.
You can either follow the steps above, or just go in the "Extensions" page and remove "Microsoft.ApplicationInsights.AzureWebSites". I recommend doing this while the website is stopped so all files can be removed without any of them being locked by your running process.

Still getting "StartupBootstrapper failed".
I followed the instructions above.
I stopped the app service, disabled all the Insights features, hit apply, then disabled App Insights, and then hit apply then started the app service back up.
The "D:homeSiteExtensionsMicrosoft.ApplicationInsights.AzureWebSites2.6.5..." is still in there.
I don't have a "Microsoft.ApplicationInsights.AzureWebSites" extension installed.
I do have the "ASP.NET Core Extensions | 2.1.1" extension installed.
All the App Insights related App Settings have "disabled" as their values.

Here's what my processes look like:
image

@joshmouch you can safely remove the "D:homeSiteExtensionsMicrosoft.ApplicationInsights.AzureWebSites" folder. This will ensure the extension is properly removed. The new enablement blade should have done that for you, we'll investigate further why that did not happen.

@clguimanMSFT I think I was previously confusing a "self-contained" dotnet application with a "self-contained" asp.net core application that uses full framework (4.7.2). When your Asp.net Core app uses the full framework, does "self-contained" vs. "framework dependent" even apply? If not, then I'm getting the exceptions noted above when deployed using full framework. In other words, I deploy my app to App Services using full framework, but am unable to use the App Insight Extensions.

When the app targets the full frameworks it's still considered a self contained app, so the limitation still applies.

@clguimanMSFT Thanks! So to clarify: Any ASP.Net Core application that targets full framework (e.g. .Net 4.7.2) cannot use some of the App Insight features (e.g. App Insights Profiler).

@joshmouch the Application Insights site extension is not able to automatically inject ApplicationInsights SDK and SnapshotCollector is a self-contained app (it also includes ASP.NET Core apps that target full framework) so you need to enable those from code (https://github.com/aspnet/Hosting/issues/1398#issuecomment-387842930)
The Application Insights Profiler continuous web job (ApplicationInsightsProfiler3) will still be installed as long as your AppService has the 'Always On' feature turned on (it doesn't cost extra, you get billed for the App Service Plan)

I am getting this error with a netcoreapp2.1 targeted app as well, when the App Insights extension is enabled. Any idea why?

@georgiosd is it a self-contained app? If so, please read the comment above.
Otherwise please enable extra logging by following these steps (use Kudu):

  1. Update the aspnetCore node in web.config in d:homesiteswwwroot with the following props:
    startupTimeLimit="3600" stdoutLogEnabled="true" stdoutLogFile="\?%home%LogFilesstdout"
  2. Add the following app setting: COREHOST_TRACE=1
    Once COREHOST_TRACE is enabled, your application will start very slowly, you should disable this after you collect the logs.
  3. Navigate to your website, and in the mean time look into d:homeLogFiles. You should see a file the starts with "stdout". Wait until that file has the StartupBootsrapper error in it along with a lot of traces coming from the dotnet runtime.

Please send that file to [email protected] and I'll investigate the issue.

@clguimanMSFT don't know what to tell ya... I tried to re-enable and reproduce the problem but it's not happening again. Maybe some left over files conflict or something something something...

Merry Christmas!

I am also getting this error. The application is an .net core 2.2 webapp with Microsoft.ApplicationInsights.AspNetCore (2.5.1) and Microsoft.ApplicationInsights.SnapshotCollector (1.3.2) nugets installed. The app service is created/managed using a ARM template. In the ARM template I set the following appsettings to enable all features of Application Insights:

  • APPINSIGHTS_INSTRUMENTATIONKEY
  • APPINSIGHTS_PROFILERFEATURE_VERSION: 1.0.0
  • APPINSIGHTS_SNAPSHOTFEATURE_VERSION: 1.0.0
  • ApplicationInsightsAgent_EXTENSION_VERSION: ~2
  • DiagnosticServices_EXTENSION_VERSION: ~3
  • InstrumentationEngine_EXTENSION_VERSION: ~1
  • SnapshotDebugger_EXTENSION_VERSION: ~1
  • XDT_MicrosoftApplicationInsights_BaseExtensions: ~1
  • XDT_MicrosoftApplicationInsights_Mode: recommended

These are the setting that were added when I did it in the azure portal for testing.

I am guessing that I do not need all these settings when using the nugets aswell? I do not know what settings that are needed to get all features (full SQL command tracking, dependency tracking, profiler, snapshot debugger, exception snapshots etc) of Application Insights enabled using ARM templates.

Closing this issue as there's no action on ASP.NET here. @clguimanMSFT what repo (if any) folk should file bugs/discuss issues on this? Thanks.

Please file future issues in ApplicationInsights-aspnetcore

still getting same error from Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices.
Could not load file or assembly 'StartupBootstrapper, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Reflection.RuntimeAssembly.nLoad","level":0,"line":0}
{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Reflection.RuntimeAssembly.InternalLoadAssemblyName","level":1,"line":0}
{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Reflection.Assembly.Load","level":2,"line":0}
{"assembly":"Microsoft.AspNetCore.Hosting, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60","method":"Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices","level":3,"line":0}

@crookedbard can you provide me with a repro? These failures get logged but should not prevent the application from loading.

  • Are you using ASP.NET Core on .NET Framework or .NET Core?
  • Do you have Application Insights configured?

@crookedbard Does your app fail to start? If so, could you please file another bug with your repro, and cc me and @davidfowl.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BrennanConroy picture BrennanConroy  路  3Comments

guardrex picture guardrex  路  3Comments

ipinak picture ipinak  路  3Comments

FourLeafClover picture FourLeafClover  路  3Comments

githubgitgit picture githubgitgit  路  3Comments