castle-windsor

How can I configure a Factory with the possible providers?

断了今生、忘了曾经 提交于 2019-12-13 03:23:54
问题 I have three assemblies: "Framework.DataAccess", "Framework.DataAccess.NHibernateProvider" and "Company.DataAccess". Inside the assembly "Framework.DataAccess", I have my factory (with the wrong implementation of discovery): public class DaoFactory { private static readonly object locker = new object(); private static IWindsorContainer _daoContainer; protected static IWindsorContainer DaoContainer { get { if (_daoContainer == null) { lock (locker) { if (_daoContainer != null) return

Using Castle Windsor configuration files is it possible to delegate to another item declaration?

泪湿孤枕 提交于 2019-12-12 20:13:52
问题 Using Castle-Windsor, is it possible to declare a type once and use this declaration for multiple Ids rather than writing it out in full each time. E.g. we have class Widget that implements IFoo and we want the keys "IFoo.A" and "IFoo.B" to get a Widget from Castle. I want to do something like <id="IFoo.Main" type="IFoo" service="Widget"/> then <id="IFoo.A" giveme="IFoo.Main/> <id="IFoo.B" giveme="IFoo.Main/> Thanks. 回答1: What your are looking for is forwarded types I believe... take a look

What is the right way to deal with exceptions in Castle Windsor's UsingFactoryMethod?

谁说我不能喝 提交于 2019-12-12 20:08:57
问题 I'm using the Nhibernate persistence facility from Windor's tutorial: Kernel.Register( Component.For<ISessionFactory>() .UsingFactoryMethod(config.BuildSessionFactory) .LifeStyle.Singleton, Component.For<ISession>() .UsingFactoryMethod(k => k.Resolve<ISessionFactory>().OpenSession()) .LifeStyle.PerWebRequest); Sometimes my call to config.BuildSessionFactory will fail (maybe my mappings are wrong, or my connection string is invalid or whatever). In the debugger, I can see the Nhibernate

Windsor composite lifestyle for asp.net process

浪子不回头ぞ 提交于 2019-12-12 19:25:17
问题 I have an asp.net process which also consumes messages from a servicebus (MassTransit). For webrequests my database session is resolved with a PerWebRequest lifestyle. But when the process consumes a message from MassTransit I need the database session to have another lifestyle, as no HttpContext is available. I have made this: public class PerRequestLifeStyleManager : ILifestyleManager { readonly PerWebRequestLifestyleManager perWebRequestLifestyleManager; readonly PerThreadLifestyleManager

How do i use WindsorInstaller across multiple assemblies for registration

人走茶凉 提交于 2019-12-12 19:23:47
问题 I am using Castle Windsor to handle my Dependency Injection and it has been working great up until now. However, i am now trying to extend my project and add some additional libraries - im now struggling to figure the best way to leverage Castle. I currently have the following assemblies MyProject.Interfaces (contains IDBContext interface) MyProject.BusinessLogic (contains the Castle Windsor implementation) MyProject.DataAccess (contains implementation of IDBContext) I currently have an

How to resolve Castle.Windsor and MoQ version conflicts for Castle.Core assembly

99封情书 提交于 2019-12-12 18:33:24
问题 In my project I need to use simultaneously Castle.Windsor and Moq dlls. Windsor requires Castle.Core also to be referenced in the project. Problem starts when I try to use methods from Castle.Core: Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(...); Problem1: If I use Moq.dll from NET40 folder, I got built error "The type 'Castle.DynamicProxy.Generators.AttributesToAvoidReplicating' exists in both '...\Windsor\dotNet40\Castle.Core.dll' and '...\MoQ\NET40\Moq.dll'" Problem2:

ASP.NET MVC3 - Use DependencyResolver AND Windsor Castle: Why?

可紊 提交于 2019-12-12 16:31:32
问题 Can somebody shine a little light for me? I've got my website all running using Windsor Castle. I have a controller factory and installers for controllers and services. All nice. Now I've just created a IDependencyResolver implementing class called WindsorDependencyResolver with a straigh-forward implementation: public class WindsorDependencyResolver : System.Web.Mvc.IDependencyResolver { private readonly IKernel _kernel; public WindsorDependencyResolver (IKernel kernel) { _kernel = kernel; }

Medium trust share webhosting site with Castle Windsor

风格不统一 提交于 2019-12-12 16:26:06
问题 I deployed by ASP.NET MVC 3 applications which uses Castle Windsor for DI. The application is hosted on GoDaddy's shared web hosting. I am receiving the following exception when trying to load the site. Doing some search on Google, I found that it's caused because GoDaddy hosting is medium trust. Is there any ways to solve this problem? Inheritance security rules violated while overriding member: 'Castle.MicroKernel.DefaultKernel.InitializeLifetimeService()'. Security accessibility of the

Is there a way to add an httpModule when webApi is running with the HttpSelfHostServer?

為{幸葍}努か 提交于 2019-12-12 16:19:07
问题 I have a MVC4 webapi controller. It has no parameter-less constructors. So, i use Windsor dependency resolver and everything is fine when work under System.Web.Http.WebHost. But, when I try to use HttpSelfHostServer, i get the exception message: Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule To fix this add <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> to the

Use Enum as Parameter in Windsor Configuration File

主宰稳场 提交于 2019-12-12 14:36:54
问题 how would I preset a Windsor configuration file parameter with an Enum specified entry such as "EntryType" below? I currently have this: <component id="test.service" service=".." type=".." lifestyle="transient"> <parameters> <entryType>EntryType.Test</entryType> </parameters> </component> Where .. obviously represents the full namespace and assembly. But receiving this error: Could not convert from 'EntryType.Test' to Business.Common.Services.Core.TestService+EntryType. 回答1: Written like this