问题
I'm having problem with MSTest, Here the issue
- Open VS2019
- Make sure that package management is set to [PackageReference]
- Create a .Net Framework test project
- Add Nuget package Microsoft.Extentions.Configuration last version (3.1.3.0)
- Add the code below
- Run test
- ==> Test fail with error [Cannot load file or assembly Microsoft.Extensions.Configuration.Abstractions, Version=3.1.0.0 ...] error
PS : using package.config instead of PackageReference solve the issue. Downgrading to Microsoft.Extentions.Configuration to 3.1.0.0 fixes the issue too
What's the problem here ?
Thanks
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace TestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var configuration = new ConfigurationBuilder().Build();
Assert.IsNotNull(configuration);
}
}
}
回答1:
Resolved by enabling auto binding redirection
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
回答2:
Even though I fixed my problem, it's not clear for me why it's requesting version 3.1.0.0 when I added version 3.1.3.0. I looked at package dependencies, and i didn't find any other package referencing a lower version. If some one has an idea or a simple thought just drop an answer here.
Thanks.
来源:https://stackoverflow.com/questions/61449325/cannot-load-file-or-assembly-microsoft-extensions-configuration-abstractions-v