castle-windsor

Using IoC container as a service locator for HttpHandler

落爺英雄遲暮 提交于 2019-12-11 07:28:45
问题 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. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) So not sure what is happening there???

Windsor Resolve dependencies using a key

吃可爱长大的小学妹 提交于 2019-12-11 06:48:08
问题 I have registered multiple instances of an Interface using castle Windsor in the following way: ServiceLocatorHelper.Register( Component.For<ISerializerAdapter>() .ImplementedBy<SerializerAdapter>(), Component.For<IDriver>() .ImplementedBy<FileDriver>() .Named(SerializationType.Binary.ToString()), Component.For<IDriver>() .ImplementedBy<XmlDriver>() .Named(SerializationType.Xml.ToString()), Component.For<IBroker>().ImplementedBy<Broker>() ); The dependencies are in the following way: +

Castle Windsor PerWebRequest LifeStyle and Application_EndRequest

风格不统一 提交于 2019-12-11 06:24:51
问题 I'm registering some components related to Linq2Sql using PerWebRequest lifestyle. I see them get created, but they get destroyed before my global's Application_EndRequest method gets called. Is that by design? Does anyone know a work around? I want to call commit on my UnitOfWork object to submitchanges() at the end of every request. In addition to using the Global.asax Application_EndResult, I've also tried an IHttpModule with the same results. I'm using Castle 2.0. Here's how I'm

Castle Windsor delegate-based factory: passing parameters to the constructor

笑着哭i 提交于 2019-12-11 05:29:39
问题 So, I have an IConnectionFactory interface, implemented by the NMSConnectionFactory class with a constructor that looks like this: public NMSConnectionFactory(string providerURI, params object[] constructorParams) I need to create these on demand, and the providerURI will only be known at runtime. So I'm trying to use a delegate-based factory that creates IConnectionFactory s for me (let's call it connectionFactoryProvider ). After reading the Castle documentations, I've tried this: My other

Castle and NLog change connection string at runtime

别等时光非礼了梦想. 提交于 2019-12-11 05:28:57
问题 i am using the NLog built in support for castle and trying to find a way to alter the connection string at run time. this is my latest swing and miss, im sure it has to do the life cycle at this point as all of the configuration is null so i am guessing that castle has not yet wired up the guts on NLog. private const string NLogConnectionString = "NLogConnection"; public void Install(IWindsorContainer container, IConfigurationStore store) { container.AddFacility<LoggingFacility>(l => l

Need help with Castle.Windsor as an Asp.Net MVC ControllerFactory please

醉酒当歌 提交于 2019-12-11 04:58:14
问题 I'm trying to implement Steven Sanderson's WinsorControllerFactory from his pro Asp.Net MVC Framework book (great book, btw) and I'm stumbling into an issue. I'm not sure what else you'll need to know in order to formulate a response but I greatly appreciate any help in this. Thanks! Here's the code: WindsorControllerFactory public class WindsorControllerFactory : DefaultControllerFactory { private WindsorContainer _container; public WindsorControllerFactory() { _container= new

Castle Windsor: How to register by convention with delegate method?

半城伤御伤魂 提交于 2019-12-11 04:39:49
问题 I'm writing command line application and using Castle Windsor as DI. Castle Windsor is new for me, decided to learn another DI container. Otherwise I'm usually using Autofac. I'm trying to register my command line options objects by convention, but before they are registered, I need to parse them. Here is how simple registration works: container.Register(Component.For<BasicOptions>() .UsingFactoryMethod(_ => Program.ParseOptions(new BasicOptions()))); (Not sure if that is the best

If you are starting a new MVC3 project which adaption will you choose DependencyResolver or ControllerFactory with Castle Windsor?

纵饮孤独 提交于 2019-12-11 04:24:33
问题 I am new to the ioc containers and confused how to integrate a container to mvc3... There is a sample that uses ControllerFactory... https://github.com/kkozmic/ToBeSeen/blob/master/src/ToBeSeen/Plumbing/WindsorControllerFactory.cs There is a blog post that says "The MVC 3.0 IDependencyResolver interface is broken. Don’t use it with Windsor." http://mikehadlow.blogspot.com/2011/02/mvc-30-idependencyresolver-interface-is.html and from this link I think I also need to implement

Castle Windsor advanced factory registration

笑着哭i 提交于 2019-12-11 03:42:00
问题 having the class: public class SomeClass{ public SomeClass(IBlabla bla, string name){ //.... } } I can write factory: public class SomeClassFactory{ public SomeClassFactory(IBlabla bla){ //.... } public SomeClass Create(string name){return new SomeClass(_bla, name)} } And live with it. But I wonder, is there any solution to do this without such obvious factory implementation, in the same way as .AsFactory() works, but with additional parameter? 回答1: Definitely possible, and you can even do it

Exception : ComponentActivator: could not proxy AsFactoryImplementation.<FactoryType>

↘锁芯ラ 提交于 2019-12-11 03:33:08
问题 I tried this code for implement the Factory in castle windsor, but it throws and exception as shown in title of this issue. i am following the examples of Documentation here. plz point out where i am getting wrong. using System; using System.Windows.Forms; using Castle.Facilities.TypedFactory; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Castle.MicroKernel.Registration; using Castle.Windsor; namespace AsFactoryImplementation {