azure-functions-host icon indicating copy to clipboard operation
azure-functions-host copied to clipboard

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

Open mtv-tuanva opened this issue 1 year ago • 14 comments

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

mtv-tuanva avatar Aug 13 '24 02:08 mtv-tuanva

Also seeing a similar issue

jkingcynergy avatar Aug 15 '24 02:08 jkingcynergy

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.

mtv-tuanva avatar Aug 20 '24 02:08 mtv-tuanva

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

aravindM365 avatar Aug 27 '24 14:08 aravindM365

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.

ipetrouchtchak-fi avatar Aug 27 '24 16:08 ipetrouchtchak-fi

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>

aravindM365 avatar Aug 27 '24 16:08 aravindM365

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.

patrick-steele avatar Aug 30 '24 13:08 patrick-steele

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)"
    }
}

aravindM365 avatar Aug 30 '24 15:08 aravindM365

@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

patrick-steele avatar Aug 30 '24 17:08 patrick-steele

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)"
  }
}

aravindM365 avatar Aug 30 '24 17:08 aravindM365

@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

patrick-steele avatar Aug 30 '24 18:08 patrick-steele

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.

aravindM365 avatar Aug 30 '24 18:08 aravindM365

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

patrick-steele avatar Aug 30 '24 18:08 patrick-steele

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

aravindM365 avatar Aug 30 '24 18:08 aravindM365

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.<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.

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

Please suggest.

agrawalamit31 avatar Sep 23 '24 09:09 agrawalamit31

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

Any updates.. Did this work locally for you ? I am running into same issue

mprecd avatar Jan 14 '25 17:01 mprecd

If it is an error in your local setup of In-Process, you need to add this in your local.settings.json: "FUNCTIONS_INPROC_NET8_ENABLED": "1"

ekanshgarg7021 avatar Jan 23 '25 17:01 ekanshgarg7021

Hi, yes for in-proc .NET 8 this variable needs to be added for local development with Core Tools:

"FUNCTIONS_INPROC_NET8_ENABLED": "1"

This is documented here.

There's an issue here in Core Tools to either show an error, or better yet, remove the need for this flag: https://github.com/Azure/azure-functions-core-tools/issues/4155

liliankasem avatar Feb 26 '25 00:02 liliankasem

Guys, I stuck in the similar situation. I migrate from .net 6 in-process model to .net 8 with isolated model. And the error is still there, I've tried deleting the logs, clear the storage account. But they did not work. Is there some one who can fix it ? Please help me with this.

QuanNguyen292 avatar May 19 '25 07:05 QuanNguyen292

@QuanNguyen292 this issue only happened when deploying an azure function .net 8 in-process model to azure window function app. But the azure function still works fine even above error msg is showing. So, I think it's just the log issue from Azure portal side. Note: This error didn't show locally, and the function still works fine locally.

You can clear the log of error msg from azure portal manually.

I realized that, the error msg won't show if I strickly follow following steps:

  • Configure settings: + FUNCTIONS_WORKER_RUNTIME=dotnet + FUNCTIONS_INPROC_NET8_ENABLED=1
  • Upgrade function .NET Framework Version to .NET 8
  • Deploy source code to azure window function app.

mtv-tuanva avatar May 28 '25 03:05 mtv-tuanva

for me i was getting this on windows running a dotnet 8 isolated function via func start --script-root api/projectname after switching to the FunctionsApplication.CreateBuilder(...) mode.

fix was simply changing to the right directory and using func start

bzbetty avatar Jun 26 '25 10:06 bzbetty