castle-windsor

How to resolve an user repository using Windsor IoC at the start of the application?

I get an error message "Object reference not set to an instance of an object." when I try to use an UserRepos repository. Question is how can I resolve user repository at the start of the application (ASP.NET MVC) What is wrong here? public class MyApplication : HttpApplication { public IUserRepository UserRepos; public IWindsor...

Where can I find a decent tutorial/explanation of using Castle Validators with ASP.NET MVC2?

Where can I find a decent tutorial/explanation of using Castle Validators with ASP.NET MVC2? I want to go with Castle because I'm not fond of the fact that I can't test my POCOs using Data Annotations without copying the logic of grabbing the attributes and calling isValid on all of them. I'm much more fond of the fact that with Castle ...

Host WCF service with Castle-Windsor outside IIS with code only

I'm trying to host a WCF service inside a console app using Castle-Windsor 2.5 (.NET 4) with the following code: new WindsorContainer() .AddFacility<WcfFacility>() .Register( Component.For<IMyService>().ImplementedBy<MyService>() .ActAs(new DefaultServiceModel() ...

Limit instance lifetime to a single iteration

I'm working on a web application that uses a couple of services to synchronize data with external resources. The application and the services share the same data layer and use Castle Windsor to implement IoC. In the web application there is the a PerWebRequest lifestyle which limits the lifetime of an instance to the lifetime of a reque...

Windsor Configuration Standard Practices

The app I inherited uses the fluent interface for configuring our Windsor container, and it's this big glob o' configuration that's pretty disgusting. In the past I created an extension method container.AddModule and then created modules that were passed in the container and registered services a la StructureMap for the different "modul...

Registering generic types and services with Castle Windsor IoC

Hello again stackoverflowians, I thought it was about time that I learnt how to use a DI framework. I've heard a lot of good things about Castle Windsor so I decided to go with that. Now there are PLENTY of tutorials out there on how to use it, however, I cannot find much useful information about what to do when Generics get involved....

Windsor-Castle: Register All Types in assembly using config file

Hi Every one in code i can do some thing like this: container.Register(AllTypes.FromAssemblyNamed("AssemblyName")); can i do the same thing using Configuration file "Windsor.Config"??? ...

Castle ILazyComponentLoader not Intercepted

I have a ILazyComponentLoader that registers any type on demand. My container also has an IModelInterceptorsSelector. When I resolve an unknown type, the ILazyComponentLoader is invoked correctly and then the IModelInterceptorsSelector is also invoked and returns the correct interceptors, but the resulting instance (which is indeed creat...

Castle dynProxy

I have the following interface public interface ISelectable { bool Selected {get;set;} } and impl public class Selectable:Iselectable { bool Selected {get;set;} } and my impl for SelectableInterceptor public void Intercept(IInvocation invocation) { if (invocation.Method.DeclaringType.Equals(typeof(ISelectable)...

Castle Windsor and Fluent Validation as an MVC Validator

I have setup my MVC project to use Fluent Validation and Castle Windsor and everything is working wonderfully. I am using a custom Validator Factory to take into account that I am also using Entity Framework and have to account for the dynamic proxies that get wrapped around my POCO classes. Here is my CastleWindsorValidatorFactory: p...

Castle ActiveRecord Integration w/ multiple databases

Hi everyone... There is a way to use Castle ActiveRecord Integration (Castle.Facilities.ActiveRecordIntegration.dll) with multiple databases? I'm already aware of using NHibernate with multiple database and ActiveRecord as well. But applied to integration facility i don't found anything. Any suggestions? Tks!! ...

ArrayResolver in castle windsor behaves strangely

Hi, Im using windsor along with the subresolver ArrayResolver and works great besides one thing. Here the ArrayResolver works the the way it supposed to work. class SomeClass : ISomeInterface { public SomeClass(ISomeDependency[] dependecies) {} } This thing does not work ISomeDependency[] = container.Resolve<ISomeDependency[]>(...

Not possible to instantiate it as an implementation of DataModel

I just configured Castle-Windsor and am receiving this message: Type DataModel.IDepartmentRepository is abstract. As such, it is not possible to instansiate it as implementation of DataModel.IDepartmentRepository service. My Interface looks like this: namespace DataModel { public interface IDepartmentRepository { ...

Castle Windsor: XML Configuration for Dynamic Proxy without a Target

Hello, Situation: I have an interface, such as public interface ITestClass { string StringElement { get; } } There is an implementation for it: public class TestClassImplementor : ITestClass { public string StringElement { get { return "AAA"; } } } I do have a factory that creates an implementation inst...

Windows Service cannot access Castle Windsor config data in app.config

Hi all I use Castle Windsor in a couple of web apps just fine by putting the config data in web.config. So when I decided to use it in a Windows Service I thought it would be a cinch. My app.config file looks like the following: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="castle" type=...

Are there any patterns for component versioning and backwards-compatibility using Windsor?

I have to support a new input file format in a system which uses Windsor. I also need to support the old version of the input file during a transition phase. This will probably be repeated in future, and we'll again need to support the new and the next most recent format. The import processing is handled by a component, and the new ve...

Do you need to call Dispose() on IWindsorContainer?

I just noticed that the IWindsorContainer interface in Castle Windsor includes Dispose(). None of the CastleWindsor tutorials I have seen (e.g. http://dotnetslackers.com/articles/designpatterns/InversionOfControlAndDependencyInjectionWithCastleWindsorContainerPart1.aspx and http://wiki.bittercoder.com/ContainerTutorials.ashx) declare th...

IWindsorContainer - when to call Release().

When I have resolved a component using container.Resolve(), and I have finished using it, should I call Release()? At the moment I call Dispose on any IDisposable that the container has got for me. Should I not call Dispose() on the object, but instead call Release() on the container instead? Does it do the same thing? Thanks David ...

Construtor/Setter Injection using IoC in HttpHandler, is it possible??

Hi. I've ran into a rather hairy problem. There is probably a simple solution to this but I can't find it! I have a custom HttpHandler that I want to process a request, log certain info then enter the details in the database. I'm using NUnit and Castle Windsor. So I have two interfaces; one for logging the other for data entry, which a...

Method 'Generate' in type xxx does not have an implementation - S#arp - UPDATED

I've been using S#arp and have updated the Generate method in AutoPersistenceModelGenerator to work with Fluent NHibernate 1.1. I also changed its assembly name from MyProject.Data to MyProject.Infrastructure and I'm not sure which has caused the problem: public AutoPersistenceModel Generate() { return AutoMap.Assemblies...