castle-windsor

Nhibernate, WinForms, Castle Windsor: Session Management

Hi, I know the question of session management has been brought up in the past, but I could not find anything that helps me overcome my problem.. I have a number of repository classes (e.g CustomerRepository, ProductRepository etc.) which I resolve through Castle Windsor (Note: I am trying to apply the three calls pattern as outlined he...

Castle Windsor - how to resolve components based on constructor parameters

Hi all, Say I have a component like this public class MyComponent { public MyComponent(string name) { } } I basically want to have the provided constructor parameters behave as part of the component identifier when resolving it. If you've never resolved it with that set of parameters, it will instantiate a new one. In ot...

Including exception details when using a Castle WCF Facility hosted service

I'm having some trouble unit testing a bit of code while utilising the Wcf Facility for Castle Windsor. It seems to refuse to include Exception Details when an Exception is thrown, I only get to see empty FaultExceptions. This is my test setup: First, here's a stub of the service that I will be connecting to: [ServiceBehavior(IncludeEx...

ASP.NET MVC2 IoC: Looking for an example using CastleWindsor container that works with minimum config

I am looking for an example of how to configure an ASP.NET MVC2 project to use CastleWindsor container to do IoC. I keep running into problems setting it up, and for every problem there seems to be a solution on-line, but in the end I make so many changes and end up with such a verbose setup to get IoC working using CastleWindsor, that ...

Castle Windsor - Register compoents before my Facilities load. - Delay loading configuration file?

Hi, I would like to register some components in my Windsor container before my Facilities load - (so that I can use some the components in the facilities) I was thinking there should be some way to initialize windsor without a configuration file, register some components, and only then load the configuration? - this would result in tha...

How do I inject my repositories/interfaces in a class which requires an empty constructor?

In my controllers, I access my repositories like so: private readonly IProjectRepository projectRepository; public ProjectsController(IProjectRepository projectRepository) { Check.Require(projectRepository != null, "projectRepository may not be null"); this.projectRepository = projectRepository; } [Transaction] public ActionRe...

Castle Windsor Fluent Registration Problem

Hello everybody, I do have the following class: public class MainView : IHandle<MessageOne>, IHandle<MessageTwo>... I would like to register all classes implementing at least one closed version of the IHandle<> Interface with the fluent registration of Castle Windsor but it does n...

Registering generic types in Windsor container

I need to register open generic of a type in my Windsor Container. How does this thing works? container.Register(Component.For<IRepository<??>>().UsingFactoryMethod(x => x.Resolve<IDataContext>().GetRepository<??>())); Basically, I want to register IRepository as open generic and then create the repository from the IDataContext based...

Is there an up-to-date Getting Started guide for Castle Windsor

I thought I'd take a proper look at Castle Windsor and found a Getting Started page. A couple of pages down I'm instructed to download an MSI installer distribution package. The link takes me to a page full of download packages, none of which is MSI. I have no idea what I'm supposed to download. ...

Using IoC container as a service locator for HttpHandler

This question relates to my other post. Ok so after a bit more messing around I decided to do it this way. Which seems to work fine when I run it, although I'm getting the following error in NUnit: Could not load file or assembly 'Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies....

Equivalent of Spring's "parent" in Castle Windsor

In Spring Framework (both for java and .net) i can use the following definition of objects: <object id="parentObject" type="Type1" abstract="true"> <property name="name" value="parent"/> <property name="age" value="1"/> </object> <object id="childObject" type="Type2" parent="parentObject"> <property name="name" value="override"/>...

Castle Interceptor to Selectable interface

public interface ISelectable { bool Selected { get; set; } } public class Selectable : ISelectable { #region ISelectable Members public virtual bool Selected { get; set; } #endregion } [Behavior(0, typeof(ISelectable))] public class SelectableBehavior : IInterceptor { #region IInterceptor Members public void ...

Is there a Windsor/DynamicProxy logging aspect, I can place as an attribute to my classes/methods?

In the castle stack? after the answer I came up with this: namespace Limpens.Windsor.LoggingAspect { using System; using Castle.Core; using Castle.Core.Interceptor; using Castle.Core.Logging; using Castle.MicroKernel; using Castle.MicroKernel.ModelBuilder; public class LoggingContributor : IContributeCompon...

Allow optional (null) property injection in Castle Windsor via factory method?

I've registered a component container.Register(Component.For<XType>() .LifeStyle.Is(LifestyleType.Transient) .UsingFactoryMethod(SomeMethod)); and am currently using this for property injection on my ASP.NET MVC controllers. However - my current problem is that SomeMethod can return null sometimes. Castle is not all too happy about...

Castle Windsor Component registration of multiple interface on a single service

hello. i am trying to implement multiple Service Contracts via a single WCF. i am trying to run this code: return new WindsorContainer() .AddFacility<WcfFacility>() .Register( Component.For<IServiceBehavior>().Instance(metadata), Component.For<IServiceBehavior>().Instance(debu...

Windsor Castle IoC Thread Safety Static Variables

I have a question for the Ioc gurus out there. I am working with a co-worker to wrap our minds around Castle Windsor IoC. We are having a difference of opinion about static Domain Service objects within asp.Net webforms. We have a static factory called BLServiceFactory in our Infrastructure layer that retrieves the container. public sea...

DI with WCF -- Where do I initialize the Windsor Container when using WAS hosting?

Hi, I was reading an exellent article about how to use dependency injection with WCF Services. Unfortunately, it only shows how to instantiate and register the Windsor Container in a global.asax file. I'm looking to use WAS for my hosting so global.asax will not get called. Does anyone know where I should register the container? Do I...

How do you register a component in Castle which takes another component as a parameter in code?

What is the correct way to pass another component into Eq()? _container.Register( Component.For<IDocumentManagementServiceProvider>() .ImplementedBy<DocumentumServiceProvider>() .Parameters(Parameter.ForKey("credentials").Eq(?) // <---right here Solution: _container.Register( C...

MVC 2 Validation Attribute Unit Testing Using IoC

I am currently writing some unit tests for an ASP.NET MVC 2 controller and having some issues with the MVC 2.0 validation attributes. The validation attribute in question uses a repository to check that no duplicate names exist in the current data source, and I would like to replace this repository with a fake one during my unit test. I ...

Castle Keeps giving me a System.TypeLoadException: Method 'myMethod' does not have implementation?

System.TypeInitializationException: The type initializer for 'XXX' threw an exception. ---> System.TypeLoadException: Method 'GetDocuments' in type 'YYY' from assembly 'ZZZ, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.. I am getting the above error when trying to resolve an object with Castle...