castle-windsor

How can I pass the correct instance of a type to an MVC Controller using Castle Windsor?

I have a problem that I can't seem to resolve. I'm sure it's simple, but I honestly cannot figure it out. I have a simple type that I reuse on multiple controllers. The problem that I'm faced with is that it's the SAME type with different configurations. I need different instances of this type to be used on different controllers. I've du...

MVC 2 and castle ioc

Hi, I am trying to upgrade my mvc 1 app to mvc 2. Previously I was using Castle Core 1.1.0 but had to get the latest version 2.5 to work with mvc 2. I now get the following error. Could not load file or assembly 'Castle.Core, Version=2.5.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located as...

Castle.Microkernel - could no load file or assembly

Hello, I was using Castle project libraries in the one of the projects, but now other projects does not work because it is now required to use this library. When I start project it shows exception: Could not load file or assembly 'Castle.MicroKernel' or one of its dependencies. The system cannot find the file specified. web.config, mac...

Can IWindsorContainer be instantiated through a static method?

I'm still groping around a bit with Castle Windsor. At the moment all my pages which need an IWindsorContainer instantiate one themselves through a property: private IWindsorContainer WindsorContainer { get { if (_windsorContainer == null) { _windsorContainer = new WindsorContainer(new XmlInterpreter(Server...

Can you add a dependency to a Castle component that was auto-registered?

I generally use StructureMap, but on a current project I'm using Castle Windsor (2.1). I've found some code to auto-register types and interfaces: _container.Register(AllTypes.Pick().FromAssembly(GetType().Assembly).WithService.FirstInterface()); However I would like to add a string dependency to one of the types. I can do this witho...

AutoMapper / Castle - Inheritance security rules violated while overriding member

I am getting the following exception when calling any of my Mapper.Map methods. Inheritance security rules violated while overriding member: 'Castle.Core.Logging.LevelFilteredLogger.InitializeLifetimeService()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden. I am us...

How to go about reducing ASP.NET MVC application startup Memory Footprint?

I have an ASP.NET MVC application that also employs the typical NHibernate / Castle stack. On startup, the application's memory footprint sits around 190Mb and I wish to be able to run multiple isolated AppPools, each of which will serve a different domain. This is before really hitting anything serious in the database or putting anythin...

Castle Windsor 2.5 Breaking Changes

I have code that was previously adding ExtendedProperties to components like component.ExtendedProperties( new { prop = someObject }); This method is no longer available and the constructor for Property is marked internal. Is there a new way of doing this for v2.5? Specifically, I have a custom ComponentActivator that needs some in...

Clay and Castle Windsor 2.5

I've just downloaded the dynamic object framework Clay and am running into issues regarding castle project versions. Clay uses functionality from v2.0 of "castle" whilst I have a project which has been started referencing v2.5. Needless to say just to make matters more interesting I'm a complete beginner in all things "Castle" and IoC. ...

What happens between TestMethods in MS Visual Studio Unit Tests

The title says it - What happens between TestMethods in MS Visual Studio Unit Tests? I have a bunch of TestMethods in a TestClass that has a TestInitialize method. The TestInitialize method internally loads a Type via Reflection (eg. Type.GetType("MyContainer, MyContainerAssembly") ). MyContainer is a class that inherits from WindsorCo...

No component for service in NHibernate web application

I am using NHibernate in my web application. At one point it enters a loop (multiple threads may be looping) where it makes many calls to the database. It works fine for a while then will fail with the following error (when I call UnitOfWork.Start()): No component for supporting the service Rhino.Commons.IUnitOfWorkFactory was foun...

AutoMapper classes with a Transient lifestyle in IoC

I'm using AutoMapper to map domain entities to view models in an Asp.Net MVC app. I register these mapping classes in Castle Windsor so they are available to the controller thru ctor dependency injection. These mapping classes has a virtual CreateMap method where I can override AutoMapper's mapping, telling it how to map fields from th...

Replacing following code with IoC (Castle Windsor)

If I had the code below what are the best practise / design considersations for replacing it with IoC (we are looking to use Castle Windsor). As the "using" statement is responsible for creating the connection object, you can't inject that directly into the constructor or the method. Note: Using SQL connection as what appears to be a c...

Castle Windsor + ISubDependencyResolver: weird issues

Castle Windsor 2.5. This fails. Why? Is it designated beahvior or a bug? Seems sub dependency resolvers are not even queried when resolving top-level services. class Program { class Resolver :ISubDependencyResolver { public object Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel mod...

Does Castle Windsor have a Static Class Similar to StructureMap's ObjectFactory?

I am currently making the move from StructureMap to Castle Windsor. Using StructureMap, you can bootstrap the framework in one central location, and then call ObjectFactory.GetInstance anywhere in your code to grab an instance using that configuration. So conceptually there is a single container that you configure, and calls to the Obj...

Castle Windsor: master controller not resolving the registered components in the container

Having the code below in my Global.asax.cs and two controller (one based on a the other: MasterController) I don't seem to find how can I resolve the repository register in my WindsorContainer from the MasterController... the same applies in the HomeController and works perfectly... what am I doing wrong? Global.asax.cs: private IWinds...

Castle Windsor Interceptor and Unit Of Work

Is Castle Windsor's Inteceptor mechanism considered to be a good/effective way of implementing the Unit of Work pattern? My project involves Castle Windsor, the NHibernate Facility and of course NHibernate - all used in self-hosted WCF services. Each service method normally requests from the Windsor container an instance of a helper cl...

How to avoid cyclic behaviour with Castle Windsor's CollectionResolver?

I am using Castle Windsor 2.5 in my application. I have a service which is a composite that acts as a distributor for objects that implement the same interface. public interface IService { void DoStuff(string someArg); } public class ConcreteService1 : IService { public void DoStuff(string someArg) { } } public class ConcreteServi...

How do i implement Inversion of control using Castle Windsor

Hi I having some problems implementing IOC using windsor. I have several different implementations of a data access class and i want to use windsor to be able to specify which data access class to use when using a business object. See the code below public interface IPersistable { bool Save(); bool Delete(); } public class Add...

Windsor container components not available on first controller action

Hi there, I'm using a configuration within the global.asax.cs to register the components but it looks the container hasn't been initialized yet at the first http request (HomeController > Index action) and it gives me a "The ObjectContext instance has been disposed and can no longer be used for operations that require a connection." erro...