castle-windsor

Castle Windsor: Is there a way to override a component Id?

I have the following bit of registration code: Component.For<IPublishingService>().ImplementedBy<UseStoredProcedureToPrintService>(), Component.For<IConfirmationDialog<AutomatedTransaction>>().ImplementedBy<ShipmentConfirmationDialog>().Named("ShipmentConfirmationDialog"), Component.For<IConfirmationService<AutomatedTransaction>>().Impl...

Adding additional dependency using Castle Windsor

Hi there I am tying to register a component into the IWindsorContainer i.e. _container.Register(Component.For<IView>().ImplementedBy<View>()); _container.Register(Component.For<Presenter>()); When i resolve the view i want to also want to create the Presenter so that i can subscribe to any events that are generated by the view. Can ...

External Controllers and Castle

FIXED: I'm leaving this in case some other Joe Schmo needs it. In the controller factory you need to register the controller so that it can be found when called. container.Kernel.AddComponent("ExternalResources", typeof(InteSoft.Web.ExternalResourceLoader.ExternalResourceController), LifestyleType.Transient); Do it like so: // Instanti...

Castle Windsor: Best way to log when a component is registered?

I would like to log when a component (interface and implementation) is registered to my container. What is the best way of doing this? I found the IKernelEvents interface that looks promising but I can't find how to actually use it. ...

Windsor-like Xml configuration <include> in Unity

Hello, I have common DI configuration for my application and integration tests. However, a couple of the dependencies do differ; e.g. my IEMailGateway in the integration tests uses a decorated version so that 'real' e-mails are not sent. In Windsor I would have the 'main' configuration xml file and simply add an include to add the var...

Tracing Castle Windsor Resolution of Type

Is there any way to trace exactly what Castle Windsor is doing when resolving a type? I am looking for a TraceSource name, or log4net (etc.) logger name. If this does not exist where is the best place to hook into the framework to provide my own logging code? Reason being is we have deployed the exact same build/config of our software ...

Castle Windsor: Registering Generic Classes with a Non-Generic Interface

I have a class that has several dependencies: public class ThirdPartyDataSearchCoordinator<TItem, TSearchCriteria, TResult> : IThirdPartyDataSearchCoordinator where TItem : class, IThirdPartyItem { public ThirdPartyDataSearchCoordinator(IDataMiner<TSearchCriteria, TResult>[] miners, IThirdPartyItemRepository<TItem> repositor...

Windsor Castle: good sources for documentation, tutorials

I'm trying to assemble a list of good documentation sources for Windsor Castle (apart from analyzing its source code). I'm especially interested in documentation about the fluent configuration API. Here's what I've found myself: BitterCoder's Wiki Container Tutorials DimeCast's Setting up Castle Windsor for Auto Registration http://usi...

Castle Interceptors With Fluent Interface

I'm trying to get an interceptor I've written to work, but for some reason it doesn't seem to be instantiating the interceptor when I request my components. I'm doing something like this (forgive me if this doesn't quite compile, but you should get the idea): container.Register( Component.For<MyInterceptor>().LifeStyle.Transient, ...

CastleWindsor filling the class fields too

I am a beginner using castle windsor; and kinda introduced to it with Apress Pro Mvc book. In the project that I am working at; I use castlewindsor controller factory instead of mvc controller factory; so i can have parametrized constructors and i can inject the dependencies. Is there a way to tell the windsorcontroller factory to inject...

Register all Controllers programatic in Castle Windsor container from all assemblys

I use this code... container.Register( AllTypes .FromAssembly(Assembly.Load("MyNamespace.Dashboard")) .BasedOn<IController>() .Configure(component => component.LifeStyle.Transient .Named(ControllerNameFromType(component.Implementation))) ); ... to register...

Castle Windsor Interface resolution via reflection

Hi all, I have encountered a small problem when trying to resolve an interface in castle using reflection. Lets say I have an interface IService, and can resolve it like this: var service = wc.Resolve<IService>(); This works as expected, but I want to call the method through reflection and can do so like this: MethodInfo method = ...

Problem with Windsor Calls to "Genericized" Methods After Adding an Interceptor

I have an application that was working fine that uses Windsor for IoC. I want to log the method calls, parameters, and execution time of all calls made to components instantiated by Windsor, so I implemented a LoggingInterceptor that implements IInterceptor, that contains: Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); ...

dependency browser that runs against an inversion of control framework

Do any inversion of control / dependency injection framworks support viewing the object dependencies that have been registered? This is not to execute the code, but to better understand it. It seems that a graph based on the information it has (class A depends on B and C, class B dependencs on C and E, etc) would really document a syst...

ASP.NET MVC / Castle Windsor / IIS6 / Modified MapRoute {controller}.aspx

Hi, I've written a web application with ASP.NET MVC. The default ControllerFactory has been replaced with Castle Windsor's Controller ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory()); The problem is that I'm using shared hosting which runs II6 so in order to get the MVC working I've had to replace the de...

WCF Castle Windsor and WAS

I have a service that is hosted in WAS. I am trying to inject this service with dependencies, but have been having trouble finding where to do this. In a WCF service hosted in IIS you can use the application_onstart event to instantiate the castle container, but this isn't available in my scenario. So, I am trying to create a custom host...

SportsStore: MVC programming issue [Castle WindsorControllerFactory]

Hey all! So I've been following Steven Sanderson's book called Pro ASP.NET MVC Framework, and I'm running into an exception: No parameterless constructor defined for this object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the err...

Castle IoC - How can I prevent registered components being resolved as dependencies?

I'm using the method described by Bojan Resnik in this question to resolve instances of classes that are not registered in the Windsor container. The problem is that I don't want these classes to be available as "services" to other resolved instances. For example, given the following classes: class Order { public Order(ITaxCalculat...

Can castles windsor container return the same instance of a component implementing 2 interfaces

Is is possible with the Castle Windsor Container to have one component implement two different interfaces and then when resolving it to return the same component instance? For example; var windsor = new WindsorContainer() .AddComponent&lt;InterfaceA, ClassAB>() .AddComponent&lt;InterfaceB, ClassAB>(); var classAB1 = windsor.Re...

Circular dependecy in winforms app using Castle Windsor

Hello, I was experimenting a little bit with Castle winforms in a winforms project. I wanted to register all my form dependencies with Castle windsor. This way I would have a single instance for all my forms. Now I have some problem though. I'm in a situation that form x has a dependency on form y and form y has a dependency on form x...