castle-windsor

Castle interceptor does not intercept a method on an MVC Controller during unit test

I have a .net test class. In the Initialize method, I create a windsor container and make some registrations. In the actual test method, I call a method on the controller class but the interceptor does not work and the method gets directly called. What are potential reasons for this? Here is all the related code: Test.cs: private Some...

Vague MVC and Castle Windsor question. Sorry...

I have inheritted some code in which the MVC Controller classes all get their constructors called by Castle....DefaultProxyFactory.Create() somewhere along the line (the call stack drops out to the <external code>, which isn't helping.) So, basically, how would I go about finding out where Castle is being told how to call the constructo...

How to Use Windsor without Property Injection

I am attempting to use the WindsorContainer, but I need to turn off Property Injection for the entire container. Here's the code I was trying, but it doesn't seem to have an effect. this.Container = new WindsorContainer(new XmlInterpreter(new ConfigResource("Dependencies"))); this.Container.Kernel.ComponentModelBuilder.RemoveContributo...

How do I set up Array/List dependencies in code with Castle Windsor?

Hi, I have the following classes: class Repository : IRepository class ReadOnlyRepository : Repository abstract class Command abstract CommandImpl : Command { public CommandImpl(Repository repository){} } class Service { public Service (Command[] commands){} } I register them in code as follows: var container = new Contai...

Using Castle Windsor with FluentValidation In MVC

I'm working on getting FluentValidation working with Castle Windsor. I already have a wrapper around Castle Windsor. Here is the code for that: public class ResolveType { private static IWindsorContainer _windsorContainer; public static void Initialize( IWindsorContainer windsorContainer ) { _windsorCont...

Castle Windsor: Inject NameValueCollection vs. Dictionary

I've already done many configs where dictionaries are passed into services in the <parameters> block. But what I find myself needing right now is to build a NameValueCollection (allowing multiple entries with the same key) or a Collection of KeyValuePair objects. The reason for this is im not using this dictionary to look up b when giv...

Castle windsor registration

interface IUserService class LocalUserService : IUserService class RemoteUserService : IUserService interface IUserRepository class UserRepository : IUserRepository If I have the following interfaces and classes, where the IUserService classes have a dependency on IUserRepository. I can register these components by doing something lik...

Windsor don't resolve class constructor dependency

I have code (simplified) Configuration: _container.AddComponent<IRepository<Project>, FakeProjectRepository>(); var instance = new List<Project>(); _container.Kernel.AddComponentInstance<IList<Project>>(instance); Class: class FakeProjectRepository: IRepository<Project> public FakeProjectRepository(IList<Project> entities) { ...

Rescuing a failed WCF call

Hello, I am happily using Castle's WcfFacility. From Monorail I know the handy concept of Rescues - consumer friendly results that often, but not necessarily, contain Data about what went wrong. I am creating a Silverlight application right now, doing quite a few WCF service calls. All these request return an implementation of public ...

Passing an instantiated class to concrete class derived by Castle Windsor

I have a system that I'm using to test some new architecture. I have the following setup (In MVC2 .Net - C Sharp): View < Controller < Service < Repository < DB I'm using Castle Windsor as my DI (IoC) controller, and this is working just fine in both the Service and Repo layers. However, I'm now at a point where I would like to pass an...

Config file interpreter for Silverlight version of Windsor Container

Silverlight version of Windsor container does not provide XmlInterpreter() for reading bindings from config file. Could someone suggest how can I implement my own interpreter? The online document suggest reading a configuration file, creating an instance of IConfiguration and registering them into IConfigurationStore. How and where can...

Castle Windsor : Configure a generic service and provide a non-generic implementation fails

Using Castle Windsor, I want to configure a generic service with a type parameter; and have it implemented by a known concrete type that implements the service with a specific type as the generic parameter. Expressed as a unit test, I would like to get the following to work: [TestClass] public class WindsorTests { [TestMethod] p...

Using FluentValidation with Castle Windsor and Entity Framework 4.0 (POCO) in MVC2

This isn't a very simple question, but hopefully someone has run across it. I am trying to get the following things working together: MVC2 FluentValidation Entity Framework 4.0 (POCO) Castle Windsor I've pretty much gotten everything working. I have Castle Windsor implemented and working with the Controllers being served up by the ...

using MEF with NHibernate and windsor

I have an ASP.net MVC application that is using NHibernate under the covers for data access. I'm using the Windsor container to handle injecting ISession references into each controller. This works great, but now I'm looking to expand my application with a pluggable architecture so that I can have a core product and specific add-ons. ...

C#, DI, IOC using Castle Windsor

Hi! Am working on a design of a project. I would like to move the implementation away hence to decouple am using interfaces. interface IFoo { void Bar(); void Baz(); } The assemblies which implemented the above interface would be drop in some predefined location say "C:\Plugins" for eg: project: A class A : IFoo { } when compile...

FluentNHibernate 1.1 / Castle 1.1 dependency

I would like to upgrade my FluentNHibernate to version 1.1, but I found out it uses Castle.Core 1.1. I use Castle.Windsor 1.2 in my app which works with Castle.Core 1.2. I now need to find a version of Castle.Windsor that uses this earlier version of Castle.Core, but I can't find it anywhere. What do you recommend I should do? Wait...

Castle, sharing a transient component between a decorator and a decorated component

Consider the following example: public interface ITask { void Execute(); } public class LoggingTaskRunner : ITask { private readonly ITask _taskToDecorate; private readonly MessageBuffer _messageBuffer; public LoggingTaskRunner(ITask taskToDecorate, MessageBuffer messageBuffer) { _taskToDecorate = taskToDec...

How can I have a Windsor IoC container that can be shared amongst my classes but not shared across multiple web requests?

I am building a set of class libraries that produce office open xml based reports and I am using a static Windsor IoC container. My problem is that one possible entry point to the reporting system is via a web front end which means that the reporting systems static IoC Container is being shared amongst multiple web requests which causes...

List all IRegistrations in WindsorContainer/Kernel

How do I get a list of all IRegistrations/ComponentRegistrations in my WindsorContainer or its kernel? I can see a way of doing this by wiring to the ComponentRegistered event and tracking there, but is there an eaiser way? Thanks. ...

How to inject UrlHelper in MVC using Castle Windsor

I have a component that has a dependency on UrlHelper that I need to register using Castle Windsor. UrlHelper in turn has depdendencies on RequestContext (and RouteCollection). Now my controller has a Url property of type UrlHelper but cannot really access this as far as I can tell. What is the most efficient way to register my UrlHelp...