Giter Site home page Giter Site logo

Comments (3)

mjeanrichard avatar mjeanrichard commented on August 21, 2024

I just managed to write a test. It seems to have something to do with the SingletonLifetimeManager.

namespace UnitTestProject1
{
  public interface ITest
  {
  }

  public class Test : ITest
  {
  }

  public class Test2 : ITest
  {
    private readonly IEnumerable<IInner> _tests;

    public Test2(IEnumerable<IInner> tests)
    {
      _tests = tests;
    }
  }

  public interface IInner
  {
  }

  public class Inner : IInner
  {
  }

  [TestClass]
  public class UnitTest1
  {
    [TestMethod]
    public void TestMethod1()
    {
      UnityContainer container = new UnityContainer();

      container.RegisterType<ITest, Test>(nameof(Test), new TransientLifetimeManager());
      container.RegisterType<ITest, Test2>(nameof(Test2), new TransientLifetimeManager());

      container.RegisterType<IInner, Inner>(nameof(Inner), new SingletonLifetimeManager());

      IEnumerable<ITest> enumerable = container.Resolve<IEnumerable<ITest>>();

      Assert.AreEqual(2, enumerable.Count());
    }
  }
}

from abstractions.

ENikS avatar ENikS commented on August 21, 2024

Unity.Container 5.10.0 works with Unity.Abstractions 4.1.1.

Unity.Abstractions 4.1.3 requires Unity.Container 5.10.3

If you decided to upgrade the container, why not upgrade Abstractions as well? Perhaps use composite Unity package to get matching set?

Feel free to reopen if issue persists with matching packages

from abstractions.

mjeanrichard avatar mjeanrichard commented on August 21, 2024

The Issue happend in the following constellation:

Project A (a Nuget Package) references:

  • Unity.AspNet.WebApi 5.10.0

Project B references:

  • Unity.Abstractions 4.1.3 (because it needs this directly)
  • the Package created in Project A (and therefore gets the reference to Unity.AspNet.WebApi 5.10.0)

With Project B you get the described Error, because nuget will fullfill the dependency on Unity.Container from Unity.AspNet.WebApi with Version 5.10.0).

To me it was just a bit confusing, that there is a breaking change from one Patch Version to the next. But everthing is solved by explicitly referencing the right packages.

from abstractions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.