Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Options'

I've been getting this error message when I try to run my Azure function v4.

System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Extensions.Options, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.'

This used to work like a week ago, and now it's throwing this error at runtime. Latest changes I did was to update EF Core to version 7. But I guess that's not relevant because that's in a different project, so not related to the function project.

These are the package references in my function project:

<PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
    <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
  </ItemGroup>

Has anyone else got it or any idea how to resolve it?

Tried removing all the Nuget packages and installing them. That didn't work. I can see the Microsoft.Extensions.Options.dll (v7) in the debug folder as well. Not sure why the runtime complains about it.

I recently updated to VS 2022 Version 17.4.1. Maybe that's the issue here?

like image 735
Thusitha Avatar asked Mar 31 '26 18:03

Thusitha


1 Answers

I have reproduced in my environment,I have observed that the same packages you have given is working fine in .NET 6 Azure functions project

And it is working fine in .NET 7 isolated when I remove Microsoft.NET.Sdk.Functions (last package).

Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified

As discussed in comments Try to degrade

Microsoft.Extensions.Configuration.Abstractions nuget package to Version="6.0.0". Try to revert back to older versions

like image 114
RithwikBojja Avatar answered Apr 03 '26 16:04

RithwikBojja