Comments (3)
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.
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.
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)
- RegisterFactory delegate should be able to call the original Resolve with overrides HOT 1
- FactoryLifetime.Scoped has wrong return type
- Fix InjectionConstructor & InjectionMethod selection with Type vs parameter of Type
- Unity.Abstractions 5.11.6 not working with Unity.AspNet.WebApi 5.0.15? HOT 3
- PerSessionLifetimeManager no longer works after upgrading to Unity.Abstraction 5.11 HOT 4
- Method "ToString" does not have an implementation exception Unity versions 5.11.8 and 5.11.9 HOT 4
- Document Unity Release versioning strategy HOT 9
- Add missing constructors to DependencyOverride<T>
- ECCN question HOT 1
- XML documentation question HOT 1
- How to return the old behaviour of Unity registration/resolve processes HOT 1
- Add name validation for PropertyOverride and FieldOverride
- DependencyOverride incorrect matches
- Remove obsolete class TypeBasedOverride
- Optimize ResolverOverride
- Fix ParameterOverrides.OnType(Type targetType)
- Resolve fails when registered with nested injection
- Unity.Extensions.Inject does not cover all cases for Arrays, Parameters, and members
- ILifetimeContainer interface changes
- Changes to IResolveContext interface
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abstractions.