Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.94k stars 441 forks source link

Error message "Error configuring services in an external startup class. ---> System.IO.FileNotFoundException : Could not load file or assembly 'System.ComponentModel, Version=8.0.0.0" when migrating to .NET 8 with in-process model #10391

Open mtv-tuanva opened 2 months ago

mtv-tuanva commented 2 months ago

I followed this guideline to migrate azure function in-process model to .NET 8 (https://github.com/Azure/azure-functions-host/issues/9951#issuecomment-2220820760). But after deploying to azure window function app, I got following error message even all functions is able working well

Microsoft.Azure.WebJobs.Script.ExternalStartupException : Error configuring services in an external startup class. ---> System.IO.FileNotFoundException : Could not load file or assembly 'System.ComponentModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. at XXX.Startup.Configure(IFunctionsHostBuilder builder) at Startup.cs : 84 at Microsoft.Azure.Functions.Extensions.DependencyInjection.FunctionsStartup.Configure(WebJobsBuilderContext context,IWebJobsBuilder builder) at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureStartup(IWebJobsStartup startup,WebJobsBuilderContext context,IWebJobsBuilder builder) at D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 162 at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureAndLogUserConfiguredServices(IWebJobsStartup startup,WebJobsBuilderContext context,IWebJobsBuilder builder,ILoggerFactory loggerFactory) at D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 130 at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseWebJobsStartup(IWebJobsBuilder builder,Type startupType,WebJobsBuilderContext context,ILoggerFactory loggerFactory) at D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 115 at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseExternalStartup(IWebJobsBuilder builder,IWebJobsStartupTypeLocator startupTypeLocator,WebJobsBuilderContext context,ILoggerFactory loggerFactory) at D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 213 at Microsoft.Azure.WebJobs.Script.ScriptHostBuilderExtensions.<>c__DisplayClass7_0.<AddScriptHostCore>b__1(HostBuilderContext context,IWebJobsBuilder webJobsBuilder) at /_/src/WebJobs.Script/ScriptHostBuilderExtensions.cs : 235 End of inner exception

How do I find the System.ComponentModel package with Version=8.0.0.0? I see the latest version from Nuget is 4.3.0 instead of 8.0.0.0.

Does anyone know the issue and help me how to fix it?

Thank you, Tuan Vo

jkingcynergy commented 2 months ago

Also seeing a similar issue

mtv-tuanva commented 2 months ago

Hi @bhagyshricompany, any feedback on this issue?

The issue happened after I deploying the .NET 8 azure function with in-process model first, then I configured the setting FUNCTIONS_INPROC_NET8_ENABLED = 1 after that. image

Notice: the error message will disappear after a day.

aravindM365 commented 2 months ago

I am stuck with this issue as well. Does this have a resolution?

ipetrouchtchak-fi commented 2 months ago

I am stuck with this issue as well. Does this have a resolution?

@mtv-tuanva, @aravindM365, try adding <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> inside the <PropertyGroup> section in your csproj file.

aravindM365 commented 2 months ago

I am stuck with this issue as well. Does this have a resolution?

@mtv-tuanva, @aravindM365, try adding <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> inside the <PropertyGroup> section in your csproj file.

It's already there in the csproj file.

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
  </PropertyGroup>
patrick-steele commented 2 months ago

Seeing the same issue on two of our function apps (running locally - Windows 11, VS 2022, haven't tried running in Azure yet)

All I did was upgrade two .NET 6 Function apps to target .NET 8 (leaving them as in-process functions). I also have the _FunctionsSkipCleanOutput set to true in my csproj file. I updated my local.settings.json to have the required settings for .NET 8 in-process support:

"FUNCTIONS_INPROC_NET8_ENABLED": "1"
"FUNCTIONS_WORKER_RUNTIME": "dotnet"

Both of these apps fail to start when I hit F5. One fails with:

Error configuring services in an external startup class. XXX: Could not load file or assembly 'System.ComponentModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

The other one fails with:

Error configuring services in an external startup class. XXX: Could not load file or assembly 'System.Data.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

In Visual Studio, I also went to Tools -> Options -> Projects and Solution -> Azure Functions. Checked to make sure I had the most recent Azure Function toolsets and they are up to date.

aravindM365 commented 2 months ago

You can try adding the Extension Bundle in host.json to resolve this issue.

{
    "version": "2.0",
    "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[4.0.0, 5.0.0)"
    }
}
patrick-steele commented 2 months ago

@aravindM365 Extension Bundles don't apply to C#. Both of our functions apps are complied C# code. Trying to use extensions results in the error:

Extension bundle configuration should not be present for the function app with pre-compiled functions. Please remove extension bundle configuration from host.json

aravindM365 commented 2 months ago

That's strange because ours is also compiled C# code but adding the extension bundle resolved the original error of this thread. Here is the complete host.json in case it helps.

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingExcludedTypes": "Request",
      "samplingSettings": {
        "isEnabled": true
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.0.0, 5.0.0)"
  }
}
patrick-steele commented 2 months ago

@aravindM365 This fixed your issue running locally? Or in Azure? I have not tested the upgraded (.NET 8) function apps in Azure yet since I can't even do any local testing due to the issue outlined in my original reply.

For reference, this is the version information the runtime dumps before I get the error about removing extensionBundle:

Azure Functions Core Tools
Core Tools Version:       4.0.5907 Commit hash: N/A +807e89766a92b14fd07b9f0bc2bea1d8777ab209 (64-bit)
Function Runtime Version: 4.834.3.22875
aravindM365 commented 2 months ago

After the .Net 8 upgrade, everything worked fine locally. I only saw the original error mentioned on this thread when I published my function app to Azure. Sounds like our issues are different.

patrick-steele commented 2 months ago

And you stuck with the in-process model, right? Or did you upgrade to the isolated one?

aravindM365 commented 2 months ago

The function apps I upgraded to .Net 8 are still in in-process model, yes.

agrawalamit31 commented 1 month ago

Hello All,

I am using Azure function and upgraded to .Net 8 with in-proc and facing below issue only at Azure not locally

Microsoft.Azure.WebJobs.Script.ExternalStartupException : Error configuring services in an external startup class. ---> System.IO.FileNotFoundException : Could not load file or assembly 'System.ComponentModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. at XXX.Startup.Configure(IFunctionsHostBuilder builder) at Startup.cs : 84 at Microsoft.Azure.Functions.Extensions.DependencyInjection.FunctionsStartup.Configure(WebJobsBuilderContext context,IWebJobsBuilder builder) at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureStartup(IWebJobsStartup startup,WebJobsBuilderContext context,IWebJobsBuilder builder) at D:\a_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 162 at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureAndLogUserConfiguredServices(IWebJobsStartup startup,WebJobsBuilderContext context,IWebJobsBuilder builder,ILoggerFactory loggerFactory) at D:\a_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 130 at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseWebJobsStartup(IWebJobsBuilder builder,Type startupType,WebJobsBuilderContext context,ILoggerFactory loggerFactory) at D:\a_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 115 at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseExternalStartup(IWebJobsBuilder builder,IWebJobsStartupTypeLocator startupTypeLocator,WebJobsBuilderContext context,ILoggerFactory loggerFactory) at D:\a_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 213 at Microsoft.Azure.WebJobs.Script.ScriptHostBuilderExtensions.<>c__DisplayClass7_0.b_1(HostBuilderContext context,IWebJobsBuilder webJobsBuilder) at //src/WebJobs.Script/ScriptHostBuilderExtensions.cs : 235 End of inner exception How do I find the System.ComponentModel package with Version=8.0.0.0? I see the latest version from Nuget is 4.3.0 instead of 8.0.0.0.

I tried adding try adding <_FunctionsSkipCleanOutput>true inside the section in your csproj file and it din't work for me.

Please suggest.