Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

c# - Microsoft.Extensions.Configuration, Version=2.1.1.0 - exception could not load file or assembly

Background: I developed a .NET Standard 2.0 Nuget package (local) for a class library with a dependency on Microsoft.Extensions.Configuration, Version=2.1.1.0. It passed unit tests and ran fine when invoked from a .NET Core 2.0 console app. However, when I added my package to an Azure Function project it caused an exception to be thrown whenever I attempted to run the azure function from the VS2017 debugger.

  • System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Configuration, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60

Question: How can I fix the problem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Copied from OPs question:

Answer: The problem goes away when I downgraded to Microsoft.Extensions.Configuration, Version=2.0.0. in my package, republished it and then reinstalled it in my Azure Function. This seems to be another example of the packages-dependency-crisis. The Nuget package manager should have caught any dependency problems with v2.1.1 when my package was added to the Azure Function project, but it didn't so it only became apparent at runtime. This is sub-optimal.

I provide the above information in the hope that others will not waste a day tracking down the same issue. It also raises the question as to how you decide what version of a package to add. Clearly in the case of Microsoft.Extensions.Configuration adding the latest stable version isn't always the best idea.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...