question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions' for .NET 6

See original GitHub issue

Starting from 1.3.1 version, WireMockServer.Start() starts to throw below exception when tests are run with NUnit.ConsoleRunner 3.15.2

System.IO.FileNotFoundException : Could not load file or assembly ‘Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60’. The system cannot find the file specified. at WireMock.Server.WireMockServer…ctor(WireMockServerSettings settings) at WireMock.Server.WireMockServer.Start(Nullable`1 port, Boolean ssl)

Test to reproduce

1- Create a unit test project

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="NUnit" Version="3.12.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" PrivateAssets="All" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.1.0" PrivateAssets="All" />
    <PackageReference Include="NunitXml.TestLogger" Version="2.1.62" PrivateAssets="All" />
    <PackageReference Include="WireMock.Net" Version="1.3.0" />
  </ItemGroup>
</Project>

With Test class

[TestFixture]
public class Test
{
    private WireMockServer server;
    [SetUp]
    public void Setup()
    {
        server = WireMockServer.Start();
    }

    [Test]
    public void SomeTest()
    {
        Assert.Pass();
    }

    [TearDown]
    public void TearDown()
    {
        server.Stop();
    }
}

And global.json

{
  "sdk": {
    "version": "6.0.400",
    "rollForward": "major"
  }
}
  1. dotnet build
  2. Run tests using NUnit.ConsoleRunner "C:\Users\br123\.nuget\packages\nunit.consolerunner\3.15.2\tools\nunit3-console.exe" bin\AnyCPUDebug\net6.0\WireMockSample.dll <!-- path to compiled project --!>

Expected behavior

Test Run Summary Overall result: Passed Test Count: 1, Passed: 1, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0

Actual

Test Run Summary Overall result: Failed Test Count: 1, Passed: 0, Failed: 1, Warnings: 0, Inconclusive: 0, Skipped: 0

Additional info

I am not sure if this should be reported on this repository or in nunit-console, but since this a regression following WireMock.Net upgrade I choose to repot it here. If you need further info, I’ll be glad to share it with you.

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
StefHcommented, Dec 20, 2022

OK, I thought this was also a dotnet tool. I’ll try this and check if it throws the same exception.

0reactions
bouchraRekhaddacommented, Mar 10, 2023

@StefH that’s good to hear. Thank you for reporting back 🙌

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Could not load file or assembly Microsoft.Extensions. ...
I noticed in the error the Microsoft.Extensions.DependencyInjection.Abstractions 2.0.0 version was requested. Downgraded to that package in ...
Read more >
.NET 6 Project couldn't load since not found Microsoft. ...
Could not load file or assembly Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0. Environment data. dotnet --info output:
Read more >
Could not load file or assembly 'Microsoft.Extensions. ...
When instatlling Sitecore Headless Rendering package it included set of files like config , Dlls , module items , and view .
Read more >
Upgrade my Azure Function from .net Core 3.1 to . ...
System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=7.0.0.0, ...
Read more >
Could Not Load File Or Assembly Microsoft.Extensions. ...
In this Azure tutorial, we will discuss how to fix the error, Could not load file or assembly Microsoft.Extensions.DependencyInjection.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found