Giter Club home page Giter Club logo

nservicebus.extensions.dependencyinjection's Introduction

NServiceBus.Extensions.DependencyInjection

NServiceBus extension to support Microsoft.Extensions.DependencyInjection

How to test locally

Nothing specific needed

nservicebus.extensions.dependencyinjection's People

Contributors

abparticular avatar adamralph avatar aleksandr-samila avatar andreasohlund avatar awright18 avatar bording avatar danielmarbach avatar davidboike avatar dependabot-preview[bot] avatar dependabot[bot] avatar heskandari avatar internalautomation[bot] avatar janovesk avatar jpalac avatar kbaley avatar kentdr avatar mauroservienti avatar mikeminutillo avatar particularbot avatar ramonsmits avatar seanfeldman avatar soujay avatar szymonpobiega avatar tchelidze avatar timbussmann avatar tmasternak avatar travisnickels avatar williambza avatar wojcikmike avatar yvesgoeleven avatar

Watchers

 avatar  avatar  avatar

nservicebus.extensions.dependencyinjection's Issues

Interface(s) of a service is always registered as `Transient`.

ServiceCollectionAdapter.RegisterInterfaces method registers interface of a target implementation type with Transient lifetime, instead of the lifetime of implementation type, that causes ComponentActivatorException for Castle.Windsor container, when that interface is resolved second times

Castle.MicroKernel.ComponentActivator.ComponentActivatorException: 
Instance {ImplementationType} of component {IInterface}_affce5c5-40e5-4a45-96aa-144328d7346e is already being tracked.
The factory method providing instances of the component is reusing instances, but the lifestyle of the component is Transient which requires new instance each time.
In most cases it is advised for the factory method not to be handling reuse of the instances, but to chose a lifestyle that does that appropriately.
Alternatively, if you do not wish for Windsor to track the objects coming from the factory change your registration to '.UsingFactoryMethod(yourFactory, managedExternally: true)''

As an example, BlobStorageDataBus which implements IDataBus is registered as a singleton while IDataBus ends up being registered as a Transient, causing above error when IDataBus is resolved second times.

Resolving non-transient types that implement IDisposable causes ComponentActivatorException with Castle.Windsor

This is a bug caused by forwarding registrations (used to map implemented interfaces to the underlying implementation) being registered in transient scope instead of the scope of the underlying implementation. While this is not strictly incorrect behavior, it can cause containers to detect a mismatch between the registration lifetime. This is the case when using Castle.Windsor and types implementing IDisposable. There are no other known containers being affected by the current behavior.

Originally raised here: #20
Fixed by #23

Who's affected

  • Customers using Castle.Windsor as their dependency injection container registering non-transient types that implement IDisposable

Symptoms

When trying to resolve a non-transient type that implements multiple interfaces as well as IDisposable the following exception might be raised

Castle.MicroKernel.ComponentActivator.ComponentActivatorException: 
Instance {ImplementationType} of component {IInterface}_affce5c5-40e5-4a45-96aa-144328d7346e is already being tracked.
The factory method providing instances of the component is reusing instances, but the lifestyle of the component is Transient which requires new instance each time.
In most cases it is advised for the factory method not to be handling reuse of the instances, but to chose a lifestyle that does that appropriately.
Alternatively, if you do not wish for Windsor to track the objects coming from the factory change your registration to '.UsingFactoryMethod(yourFactory, managedExternally: true)''

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.