castle-windsor

Castle Windsor with MVC 2.0 and Areas

Hi guys Wanted to ask a quick question regarding castle windsor and implementing IoC for Controllers in Areas. Does Castle 2.5 support MVC 2.0 areas? My Castle config works ok for my root controller in the root of my site but any area controllers are not found with a The IControllerFactory 'XXX.Castle.WindsorControllerFactory' did no...

Add attributes to class & properties on the fly

Is there anything in castle that can let me add attributes to a class on the fly? I have a dto in a project that I want to use as a data contract in a wcf service. I'd need to add a [DataContract] attribute to the class and then [DataMember] to each of the properties. I could just replicate the class in the service layer and th...

"No parameterless constructor" error instantiating Controller registered w/Windsor Container

Using MVC and trying to use dependency injection for controllers, but when I try to call a method on a controller that takes a dependency, I get the "no parameterless constructor" error. Here's my setup: ProductRepository : IProductRepository ProductService : IProductService { public ProductService(IProductRepository repository)...

How do I get the container instance back from ServiceLocation?

Is is possible to get the container instance back from ServiceLocation? I only see the ability to resolve instances of types, not register them. ...

Forwarded Types in Microsoft Unity

How to use single component for multiple services in Unity Framework? In Windsor it is configured in the following way: var container = new WindsorContainer(); container.Register(Component.For<Service1, Service2>() .ImplementedBy<Component>()); var service1 = container.Resolve<Service1>(); var service2 = co...

Castle Fluent Registration: can't override a type registered by "AllTypes" with "Component"

Inside a DLL, we've defined two classes ("Class1" and "Class2") which inherit from an interface ("IInterface") and a base class ("BaseClass"). We're using the Castle Windsor's Fluent Registration API ( http://using.castleproject.org/display/IoC/Fluent+Registration+API ) to automatically register all the classes inheriting from "BaseClas...

How can I pass a runtime parameter to a previously registered factory method using castle windsor?

I have a reporting MVC application that uses Castle Windsor. On application start up (in global.asax) all of the types are registered and then each subsequent request to the application resolves the relevant report type and windsor automatically handles the dependencies. I need to switch one of the dependant types for another depending...

Appropriate lifecycle for repository classes using Castle Windsor

When I started with Windsor I thought DI would be simple. Now it's causing me more and more confusion. A repository strikes me as a class with a singleton lifecycle. I should have a single instance of a FooRepository to load and save Foos to the database during the application's lifetime. However, each repository holds a reference to a...

Castle Monorail error - MonoRail could not resolve a view engine instance for the template 'Articles\List'

Hi I am trying to implement my first web application using Castle Monorail. Nut I am getting the following error MonoRail could not resolve a view engine instance for the template 'Articles\List' this is my controller [Layout("Default"), Rescue("GeneralError")] public class ArticlesController : SmartDispatcherController { ...

How to pass an object to the constructor through castle windsor?

Hi, I am building an object through castle windsor and my constructor accepts an argument of a custom type. How do I pass it to my object. public class ArgumentClass { int value1; string value2; } public interface IInterface { } public class CClass : IInterface { public CClass(ArgumentClass arg) { } } All my configuration is...

ASP.NET MVC + Elmah - Resource not found

I'm trying to implement ELMAH in my ASP.NET MVC application, but I'm having a problem that caused me to lose hours and hours ... and it's still unsolved. My application is running normally, but when I try and configure ELMAH and them access Home/Index, the application returns me a 404 (Resource not found). Has anyone had this problem an...

Castle windsor registering component problem

Hi I've been using Castle project for the first time and facing a problem in registering a component with the container in a console application. Following is the castle.config file: <configuration> <configSections> <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" />...

Get the corresponding View for a type from Windsor

I have the following classes defined: public interface IShapeView { void DoSomethingWithShape(Shape shape); } public interface IShapeView<T> where T : Shape { void DoSomethingWithShape(T shape); } public class CircleView : IShapeView<Circle>, IShapeView { public void DoSomethingWithShape(Circle shape) { MessageB...

Castle windsor: How to register two services with one instance of implementation?

How to register two services with one instance of implementation? I used: _container.Register(Component.For(new [] { typeof(IHomeViewModel), typeof(IPageViewModel) }). ImplementedBy(typeof(HomeViewModel)).Named("IHomeViewModel").LifeStyle.Singleton) But upper code registers two instances of HomeViewModel. ...

How can I use Castle Windsor instead of this?

I have a basic working knowledge of Castle Windsor, but I cannot figure out the DI equivalent of the below code ... private static DbModel BuildModel() { var builder = new ModelBuilder(); var types = Assembly.GetExecutingAssembly().GetTypes(); foreach (var type in types) { if (type.Na...

What is a good pattern for multi-threading in an IOC application (windsor)

I'm writing a simple photo downloader application using IOC. There is a fairly straightforward list of steps. Get list of photos to download. Check this, Check that, then download. The download can be accomplished via FTP in some cases, and via http in others, and via a web service in others. What I'm wondering, as I'm new to IOC ...

Castle Windsor, how to programmatically mimic the parameter xml syntax

Given this legacy XML configuration for Castle Windsor: > <parameters> > <AdditionalMessage>#{message}</AdditionalMessage> > <Files>#{files}</Files> > <downloaders> > <array> > <item>${HttpFileDownloader}</item> > <item>${HttpsFileDownloader}</item> > <item>${FtpFileDownloader}</item> > ...

castle windsor: how to register a list progrematically (instead with a configuration file)

I would like to register an object with a list parameter, but without using a configuration file. this is the configuration file that I currently use: <?xml version="1.0" encoding="utf-8" ?> <castle> <components> <component id="EmailParser" service="ESImportCommon.Email.IEmailParser, ESImportCommon" type="ESImportCommon....

Using Castle Windor's Logging Facility in Static Methods

I haven't been able to find much good documentation for Castle's logging facility, but reading here gives me enough to work with. I have one question though, how do you obtain a logger in situations where you can't use properties. Two examples I can think of are in a static method or inside of a struct. Bonus points for any useful docu...

Who owns the IP rights for nHibernate and Castle?

Hi, Who owns the IP rights for nHibernate and Castle? I am aware that they are open source, but is there a company/individual who holds the IP for these? Thanks ...