castle-windsor

How do I configure a single component instance providing multiple services in Castle.Windsor?

女生的网名这么多〃 提交于 2019-12-05 07:58:41
I'd like to configure the Windsor container so that a single, singleton-style instance can provide two or more services through the container. I've found that using the same type in multiple component declarations (XML-based config) will result in an instance of that type being created to provide each component's service interface, which is not the behaviour I desire. For example: interface IA { } interface IB { } class AB : IA, IB { ... } I want the one instance of AB to provide both the IA and IB services. The specific reason I want to do this is that my concrete DAO implementation extends

IoC Castle Windsor - No parameterless constructor defined for this object

六眼飞鱼酱① 提交于 2019-12-05 07:51:27
I'm getting the 'No parameterless constructor defined for this object' on my controller when the controller and its dependencies are being registered accordingly via (DI/IoC) pattern using Castle Windsor. Can someone take a look at the following and see my error because i can't see it. Code for registration on global.asax public class MyApplication : System.Web.HttpApplication { public MvcApplication() { this.container = new WindsorContainer().Install(new DependencyInstaller()); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register

How to use Castle Windsor's PerWebRequest lifestyle with OWIN

折月煮酒 提交于 2019-12-05 07:29:28
I am converting an existing ASP .Net Web API 2 project to use OWIN. The project uses Castle Windsor as the dependency injection framework with one of the dependencies set to use the PerWebRequest lifestyle. When I make a request to the server I get a Castle.MicroKernel.ComponentResolutionException exception. The exception recommends adding the following to the system.web/httpModules and system.WebServer/modules sections in the config file: <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> This doesn't resolve the error. Taking

Cannot add Controllers to Castle.Windsor in ASP.NET MVC

旧街凉风 提交于 2019-12-05 07:28:31
问题 Given the following setup, I have three assemblies. Web (ASP.NET MVC 3.0 RC1) Models Persistence (Fluent NHibernate, Castle.Windsor) This is my ControllerInstaller. using System; using System.Web.Mvc; using Castle; using Castle.Windsor; using Castle.MicroKernel; using Castle.MicroKernel.SubSystems; using Castle.MicroKernel.Registration; using Castle.MicroKernel.SubSystems.Configuration; namespace Persistence.Installers { public class ControllerInstaller : IWindsorInstaller { public void

Memory Leaks when using Entity Framework and Windsor in an ASP.NET MVC application

↘锁芯ラ 提交于 2019-12-05 06:16:34
问题 I'm having trouble getting the windsor container and entity framework working together and it may be due to a problem I've introduced myself but the net result is that I'm getting a terrible memory leaks caused. I have my application set up with an EDMX and Repositories and Services and those and the objectcontext are set to perwebrequest in the windsor configuration file I use. However when I look at the memory usage in ANTS memory profiler I see that the object context cache is still being

Can Castle.Windsor do automatic resolution of concrete types

拈花ヽ惹草 提交于 2019-12-05 06:13:51
We are evaluating IoC containers for C# projects, and both Unity and Castle.Windsor are standing out. One thing that I like about Unity (NInject and StructureMap also do this) is that types where it is obvious how to construct them do not have to be registered with the IoC Container. Is there way to do this in Castle.Windsor? Am I being fair to Castle.Windsor to say that it does not do this? Is there a design reason to deliberately not do this, or is it an oversight, or just not seen as important or useful? I am aware of container.Register(AllTypes... in Windsor but that's not quite the same

How to reuse a transient dependency in same context with Castle Windsor DI container

浪子不回头ぞ 提交于 2019-12-05 05:08:46
问题 If I have the following setup, how can I configure my container to use the same database, when objects are created in the same context public class Database { } public interface IRepository { Database Database { get; } } public interface IFooRepository : IRepository { } public interface IBarRepository : IRepository { } public class FooRepository : IFooRepository { public Database Database { get; private set; } public FooRepository(Database database) { this.Database = database; } } public

Castle Windsor Typed Factory Facility with generics

落花浮王杯 提交于 2019-12-05 02:42:14
问题 I'm trying to register a factory that could resolve an array of event handlers defined as follow: public interface IEvent { } public class EventA : IEvent { } public class EventB : IEvent { } public class EventC : IEvent { } public interface IHandler<TEvent> where TEvent : IEvent { void Handle(TEvent ev); } public class HandlerX : IHandler<EventA>, IHandler<EventB> { public void Handle(EventA ev) { throw new NotImplementedException("handle EventA"); } public void Handle(EventB ev) { throw new

I am looking for a simple yet practical and robust IOC/DI framework for .net

天大地大妈咪最大 提交于 2019-12-05 02:28:09
问题 I am going to use it in a project with less-experienced developers so a complex framework such as Spring.NET is not an option. I was thinking about: Ninject Castle Windsor StructureMap Which would present a moderate learning curve without losing flexibility? and another question - where is the correct place to put the configuration? Since the kernel/configuration on a 3-tier ASP.NET application (not MVC!!! all examples are using MVC :) ) 回答1: The great thing about proper use of DI is that you