castle-windsor

configure Castle Windosor and generic

Hi, this is my code in Global.asax WindsorContainer container = new WindsorContainer(); container.Register(Component.For(typeof(IRepository<>)) .ImplementedBy(typeof(NHRepository<>)) .LifeStyle.Transient) I've tried to translate it in a xml config file wit...

Getting a "ComponentActivatorException" using Castle Windsor from a .net 4.0 application using a .net 2.0 component.

I have an application which is being developed in VS2010, and makes use of the Castle-Windsor IoC, through a configuration file. One of the components I am registering, also developed in VS2010, references a .net 2.0 component (LeadTools), so recompiling the 2.0 project isn't an option. When the wrapping component's registration is done...

Is this a good solution to handle NHibernate Isession as PerWebRequest

Hi I Have been struggeling with NHibernate session management and have now ended up with two possible solutions to meet a session per web request. I'm using Windsor for IoC in an ASPNET mvc project First solution is to open a session in begin_request and close/dispose it again in end_request. In Windsor setup I would have container.Re...

How do I convert this WindsorControllerFactory to a UnityControllerFactory in either VB.NET or C#

I have been following along in the book Pro ASP.NET MVC Framework by Steven Sanderson. I am trying to rewrite an application to use Unity IoC instead of Castle Windsor IoC. I want the Unity implementation to register all of the controllers like the Windsor one does. Here is the WindorControllerFactory code: public class WindsorContro...

Action delegate dependency resolution using Castle Windsor

I have a class with a constructor that looks like this: public TimedWorker(int timerInterval, Action execute, ILogger logger) I am using the Castle Windsor fluent configuration and whilst the config below works, I am concerned about the way I am resolving Action. Is there a better way so that I am not always resolving the action deleg...

Problem trying to resolve type in Windsor

I have the following items in my solution: public interface IHandle<TEvent> { void Handle(TEvent event); } public interface IPresenter<TView> { } public abstract class Presenter<TView> : IPresenter<TView> { protected view; public TView View { set { view = value;} } // snip... } public interface IMy...

Logging with Castle.Facilities.Logging and log4net

Hello, i'm trying to get log4net integration for Castle Windsor working. I wrote my class with an public property of type ILogger and took the configuration in my app.config like following. <configuration> <configsections> <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" /...

What should be the strategy of unit testing when using IoC ?

After all what I have read about Dependency Injection and IoC I have decided to try to use Windsor Container within our application (it's a 50K LOC multi-layer web app, so I hope it's not an overkill there). I have used a simple static class for wrapping the container and I initialize it when starting the app, which works quite fine for ...

Caste Dynamic Proxy in Windsor Container

Hi, I've got a bit of a problem. I'm working in the Caste Windsor IOC Container. Now what i wanted to do is just mess about with some AOP principles and what i specifically want to do is based on a method name perform some logging. I have been looking at Interceptors and at the moment i am using the IInterceptor interface implemented ...

MvcContrib Windsor Setup Component With Parameter

I am using the MvcContrib library with Castle Windsor and I am having a problem with setting a parameter when I register a component. I have the following interfaces for classes that wrap a DataContext. I want to be able to specify which DataContext to use for different services because I am connecting to several databases to retrieve ...

NHibernate and Windsor assembly conflicts

Hi, I am having an issue getting Hibernate and Windsor to work together. My setup details are as follows I have two projects -DomainModel -MVCApp I have downloaded NHibernate 2.1.2 and Windsor 2.1.1 I added the following references to DomainModel from the required_Bins folder of the NHibernated download - Antlr3,Iese,log4net and NHi...

APTCA SecurityException with ASP.NET Development Server running against machine-level Full-Trust

The strange thing is that, my teammates and I are faced with APTCA SecurityException randomly when running our ASP.NET MVC website against ASP.NET Development Server (local development). Machine-level web.config shows that trustLevel is, by default, "Full". There is no override in application-level web.config. The exception happens rando...

Is there a better way to use Castle Windsor's API for Factories?

I am open to other IoC containers, such as NInject and StructureMap if they are much cleaner than this. I hear that StructureMap just introduced "containers" that may simplify this , perhaps? As the title says, is there a better way? This seems like a lot of code, just to register an object that requires a factory to create it. // Th...

Castle Windsor: Register class with internal constructor?

A Castle Windsor question: Is it possible to register a class that has an internal constructor with the container? Thanks Joni ...

Some objects created with PerWebRequest are not garbage collected at the end of web request.

Given public class a : IDisposable { public static int counter; public a() { counter++; } ~a() { counter--; } public void Dispose() { } } With registration: application_container = new WindsorContain...

Castle windsor : how to not to load all components in a castle windsor xml configuration when "Resolve" is called

I would like to use "strategy pattern" with 2 Web projects, my configuration file (and only with configuration file) : <?xml version="1.0"?> <configuration> <components> <!-- container ORM --> <component id="DALReseauContainer" type="ReseauRules.Db.BLL.DbReseauWorkingContextContainer, ReseauRules" ...

Castle-Windsor: Overwrite a component in the future

I have the following use case: I want to register all components shared between all configurations of an application. Then I would like to register a series of dynamically configured "Plugins" which are expressed as custom implementations of IRegistration. Only then do I resolve my application start point. One of the things that I wo...

Using a Dependency Injection Container in an enterprise solution with multiple different configurations

Can anyone point me towards some good documentation / code examples on how best to manage the configuration of a DI container in a scenario where you need different configuations sets? We have a layered, distributed application that has multiple entry points (ie; a website, winforms app, office plugin etc). Depending on how you are usin...

Determine if a given type can currently be resolved by a Castle Windsor container

I have a scenario where I need to know if a specific type can currently be resolved by a Windsor container. The wrinkle is that this type has dependencies. So I have a ProductRepository class that implements IRefDataRepository and depends on IProductDataProvider. I need to know if I can successfully resolve IRefDataRepository from the co...

Windsor XML configuration of generics

Hi everybody! How do i setup the configuration in XML (for Windsor Castle) for the following class? public class Repository<T> : IRepository<T> where T : class { .... } I know how to do it in code but i must use XML file Thanks in advance ...