Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 of 9 tasks
coder-candace opened this issue Oct 5, 2021 · 5 comments

Comments

@coder-candace
Copy link

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
@epasos573
Copy link
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.

@coder-candace
Copy link
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

@epasos573
Copy link
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
:

@JT-Bruch
Copy link

JT-Bruch commented Dec 6, 2021

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>

@epasos573
Copy link
Contributor

epasos573 commented Dec 7, 2021

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants