Skip to content

Version 1.15.1 and 1.15.2 - Could not load file or assembly Microsoft.Extensions.Options #292

Open

Description

@coder-candace

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

We are using the SDK in a .NET Core 3.1 Azure Function project. On startup we get the following error message.

[2021-10-05T19:14:11.699Z] A host error has occurred during startup operation '929d6984-66be-444d-b0b2-d4645ccc7549'.
[2021-10-05T19:14:11.701Z] Function-ZipWhipEngine: Could not load file or assembly 'Microsoft.Extensions.Options, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Value cannot be null. (Parameter 'provider')

In order to resolve the error we have to downgrade to version 1.14.0.
…

Issue Type (Can be multiple)

  • Build - Cannot install or import the SDK
  • Performance - Performance issues
  • Behaviour - Functions are not working as expected (such as generate URL)
  • Documentation - Inconsistency between the docs and behaviour
  • Other (Specify)

Steps to reproduce

Simply upgrade the NuGet package and try to run the project. Error will occur during startup.

Error screenshots or Stack Trace (if applicable)

image

OS and Version

  • Linux
  • Windows
  • macOS
  • MultiPlatform

Versions and Libraries (fill in the version numbers)

  • Cloudinary .NET SDK version - 1.15.1 and 1.15.2
  • .NET Core - 3.1

Activity

  1. epasos573 commented on Oct 8, 2021

    @epasos573
    Contributor

    Hi @coder-candace Could you please let me know what is the target framework set for your library Function-ZipWhipEngine (i.e. it should also be .Net Core 3.1)? The error thrown is from Microsoft.Extensions.Options which is a dependency for Microsoft.Extensions.WebEncoders (target framework .Net Core 3.1). In case, may I request a sample library that throws this exception so I could verify it further in my dev environment? Thanks.

  2. coder-candace commented on Oct 12, 2021

    @coder-candace
    Author

    Hi @epasos573 yes the target framework is .NET Core 3.1.

    I was able to further narrow down where the problem is occurring. It's happening on this line.
    [assembly: FunctionsStartup(typeof(Function_ZipWhipEngine.Startup))]

    If you remove that line, error goes away and project fires up as expected. Add it back and error returns. Problem is if we just remove this line then our Configure() override won't run and we can't set up required application settings.

    Here is a sample project demonstrating the issue
    ZipWhipEngine-Sample3.zip

  3. epasos573 commented on Oct 13, 2021

    @epasos573
    Contributor

    Hi @coder-candace Thanks for the sample code and after verifying the issue, I could see that the Microsoft.Extensions.Options is having a conflict with the Microsoft.Extensions.WebEncoders on application load.

    To replicate the issue, I have updated the sample code you have provided. I uninstalled CloudinaryDotNet package and installed the Microsoft.Extensions.WebEncoders package into ZipWhipEngine project . And launching the application throws the issue: Could not load file or assembly 'Microsoft.Extensions.Options, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. Value cannot be null. (Parameter 'provider').

    Testing the case further, I have used the Environment.CurrentDirectory instead in order to set the application base path.

        var appDirectory = Environment.CurrentDirectory;
        configurationBuilder.SetBasePath(appDirectory)
                 .AddJsonFile("appSettings.json", false, true)
                 .AddJsonFile("local.settings.json", true, true)
                 .AddEnvironmentVariables();
    

    See attached updated project
    ZipWhipEngine_Modified.zip
    :

  4. JT-Bruch commented on Dec 6, 2021

    @JT-Bruch

    I also have the same issue - basic install into a .NET Core 3.1 DLL with only these dependencies.

      <ItemGroup>
    	  <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.17" />
    	  <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.17" />
    	  <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.17" />
      </ItemGroup>
    
  5. epasos573 commented on Dec 7, 2021

    @epasos573
    Contributor

    @JT-Bruch The CloudinaryDotNet SDK is compatible with .Net Core 3.1, while the error reported above is linked to the other Microsoft packages used in the solution that are not yet compatible with .Net Core 3.1. And the proposed solution is to use other libraries that is fully functional with the version of .Net Framework/Core being used.

    As for your case, reviewing the dependencies requirements for Microsoft.Extensions.DependencyInjection.Abstractions (see Nuget link), it is only compatible with .NETStandard 2.0.

    Please take a look and see if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions