Search Results

Search found 200 results on 8 pages for 'windsor'.

Page 4/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • In Castle Windsor, can I register a Interface component and get a proxy of the implementation?

    - by Thiado de Arruda
    Lets consider some cases: _windsor.Register(Component.For<IProductServices>().ImplementedBy<ProductServices>().Interceptors(typeof(SomeInterceptorType)); In this case, when I ask for a IProductServices windsor will proxy the interface to intercept the interface method calls. If instead I do this : _windsor.Register(Component.For<ProductServices>().Interceptors(typeof(SomeInterceptorType)); then I cant ask for windsor to resolve IProductServices, instead I ask for ProductServices and it will return a dynamic subclass that will intercept virtual method calls. Of course the dynamic subclass still implements 'IProductServices' My question is : Can I register the Interface component like the first case, and get the subclass proxy like in the second case?. There are two reasons for me wanting this: 1 - Because the code that is going to resolve cannot know about the ProductServices class, only about the IProductServices interface. 2 - Because some event invocations that pass the sender as a parameter, will pass the ProductServices object, and in the first case this object is a field on the dynamic proxy, not the real object returned by windsor. Let me give an example of how this can complicate things : Lets say I have a custom collection that does something when their items notify a property change: private void ItemChanged(object sender, PropertyChangedEventArgs e) { int senderIndex = IndexOf(sender); SomeActionOnItemIndex(senderIndex); } This code will fail if I added an interface proxy, because the sender will be the field in the interface proxy and the IndexOf(sender) will return -1.

    Read the article

  • Windsor Container: How to specify a public property should not be filled by the container?

    - by George Mauer
    When Instantiating a class, Windsor by default treats all public properties of the class as optional dependencies and tries to satisfy them. In my case, this creates a rather complicated circular dependency which causes my application to hang. How can I explicitly tell Castle Windsor that it should not be trying to satisfy a public property? I assume there must be an attribute to that extent. I can't find it however so please let me know the appropriate namespace/assembly. If there is any way to do this without attributes (such as Xml Configuration or configuration via code) that would be preferable since the specific library where this is happening has to date not needed a dependency on castle.

    Read the article

  • How to use Castle Windsor with ASP.Net web forms?

    - by Xian
    I am trying to wire up dependency injection with Windsor to standard asp.net web forms. I think I have achieved this using a HttpModule and a CustomAttribute (code shown below), although the solution seems a little clunky and was wondering if there is a better supported solution out of the box with Windsor? There are several files all shown together here // index.aspx.cs public partial class IndexPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Logger.Write("page loading"); } [Inject] public ILogger Logger { get; set; } } // WindsorHttpModule.cs public class WindsorHttpModule : IHttpModule { private HttpApplication _application; private IoCProvider _iocProvider; public void Init(HttpApplication context) { _application = context; _iocProvider = context as IoCProvider; if(_iocProvider == null) { throw new InvalidOperationException("Application must implement IoCProvider"); } _application.PreRequestHandlerExecute += InitiateWindsor; } private void InitiateWindsor(object sender, System.EventArgs e) { Page currentPage = _application.Context.CurrentHandler as Page; if(currentPage != null) { InjectPropertiesOn(currentPage); currentPage.InitComplete += delegate { InjectUserControls(currentPage); }; } } private void InjectUserControls(Control parent) { if(parent.Controls != null) { foreach (Control control in parent.Controls) { if(control is UserControl) { InjectPropertiesOn(control); } InjectUserControls(control); } } } private void InjectPropertiesOn(object currentPage) { PropertyInfo[] properties = currentPage.GetType().GetProperties(); foreach(PropertyInfo property in properties) { object[] attributes = property.GetCustomAttributes(typeof (InjectAttribute), false); if(attributes != null && attributes.Length > 0) { object valueToInject = _iocProvider.Container.Resolve(property.PropertyType); property.SetValue(currentPage, valueToInject, null); } } } } // Global.asax.cs public class Global : System.Web.HttpApplication, IoCProvider { private IWindsorContainer _container; public override void Init() { base.Init(); InitializeIoC(); } private void InitializeIoC() { _container = new WindsorContainer(); _container.AddComponent<ILogger, Logger>(); } public IWindsorContainer Container { get { return _container; } } } public interface IoCProvider { IWindsorContainer Container { get; } }

    Read the article

  • Vague MVC and Castle Windsor question. Sorry...

    - by Matt W
    I have inheritted some code in which the MVC Controller classes all get their constructors called by Castle....DefaultProxyFactory.Create() somewhere along the line (the call stack drops out to the , which isn't helping.) So, basically, how would I go about finding out where Castle is being told how to call the constructors of my Controllers? I am very new to Castle, Windsor and MicroKernel, etc, and not a master of ASP's MVC. Many thanks for any pointers - sorry about the vagueness, Matt.

    Read the article

  • Can I tell Castle Windsor to create a component in a separate AppDomain?

    - by Michael L Perry
    I've created a multi-threaded service that uses Castle Windsor to create components to run on separate threads. I Resolve an component by name with parameters for each thread. I'm running into concurrency problems with a 3rd party library used by the components. I suspect that isolating those components in separate AppDomains will resolve the problem. Is there a way to have Resolve create the component using a different AppDomain? private ActivityThread NewActivityThread(ActivityInstance activityInstance) { // Set up the creation arguments. System.Collections.IDictionary arguments = new Dictionary<string, string>(); activityInstance.Parameters.ForEach(p => arguments.Add(p.Name, p.Value)); // Get the activity handler from the container. IActivity activity = Program.Container.Resolve<IActivity>(activityInstance.Name, arguments); // Create a thread for the activity. ActivityThread thread = new ActivityThread(activity, activityInstance, _nextActivityID++); return thread; } public ActivityThread(IActivity activity, ActivityInstance instance, int id) { _activity = activity; _instance = instance; _id = id; } public void Start() { if (_thread == null) { // Create a new thread to run this activity. _thread = new Thread(delegate() { _activity.Run(); }); _thread.Name = _activity.ToString(); _thread.SetApartmentState(ApartmentState.STA); _thread.Start(); } }

    Read the article

  • How do I pass dependency to object with Castle Windsor and MS Test?

    - by Nick
    I am trying to use Castle Windsor with MS Test. The test class only seems to use the default constructor. How do I configure Castle to resolve the service in the constructor? Here is the Test Class' constructors: private readonly IWebBrowser _browser; public DepressionSummaryTests() { } public DepressionSummaryTests(IWebBrowser browser) { _browser = browser; } My component in the app config looks like so: <castle> <components> <component id="browser" service="ConversationSummary.IWebBrowser, ConversationSummary" type="ConversationSummary.Browser" /> </components> </castle> Here is my application container: public class ApplicationContainer : WindsorContainer { private static IWindsorContainer container; static ApplicationContainer() { container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle"))); } private static IWindsorContainer Container { get { return container; } } public static IWebBrowser Browser { get { return (IWebBrowser) Container.Resolve("browser"); } } } MS test requires the default constructor. What am I missing? Thanks!

    Read the article

  • How do I Resolve dependancies that rely on transient context data using castle windsor?

    - by Dan Ryan
    I have a WCF service application that uses a component called EnvironmentConfiguration that holds configuration information for my application. I am converting this service so that it can be used by different applications that have different configuration requirements. I want to identify the configuration to use by allowing an additional parameter to be passed to the service call i.e. public void DoSomething(string originalParameter, string callingApplication) What is the recommended way to alter the behaviour of the EnvironmentConfiguration class based on the transient data (callingApplication) without having to pass the callingApplication variable to all the component methods that need configuration information?

    Read the article

  • How do I set up Array/List dependencies in code with Castle Windsor?

    - by SharePoint Newbie
    Hi, I have the following classes: class Repository : IRepository class ReadOnlyRepository : Repository abstract class Command abstract CommandImpl : Command { public CommandImpl(Repository repository){} } class Service { public Service (Command[] commands){} } I register them in code as follows: var container = new Container("WindsorCOntainer.config"); var container = new WindsorContainer(new XmlInterpreter("WindsorConfig.xml")); container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel)); container.AddComponent("repository", typeof(RentServiceRepository)); container.Resolve<RentServiceRepository>(); container.AddComponent("command", typeof(COmmandImpl)); container.AddComponent("rentService", typeof (RentService)); container.Resolve<RentService>(); // Fails here I get the message that "RentService is waiting for dependency commands" What am I doing wrong? Thanks,

    Read the article

  • Problem resolving a generic Repository with Entity Framework and Castle Windsor Container

    - by user368776
    Hi, im working in a generic repository implementarion with EF v4, the repository must be resolved by Windsor Container. First the interface public interface IRepository<T> { void Add(T entity); void Delete(T entity); T Find(int key) } Then a concrete class implements the interface public class Repository<T> : IRepository<T> where T: class { private IObjectSet<T> _objectSet; } So i need _objectSet to do stuff like this in the previous class public void Add(T entity) { _objectSet.AddObject(entity); } And now the problem, as you can see im using a EF interface like IObjectSet to do the work, but this type requires a constraint for the T generic type "where T: class". That constrait is causing an exception when Windsor tries to resolve its concrete type. Windsor configuration look like this. <castle> <components> <component id="LVRepository" service="Repository.Infraestructure.IRepository`1, Repository" type="Repository.Infraestructure.Repository`1, Repository" lifestyle="transient"> </component> </components> The container resolve code IRepository<Product> productsRep =_container.Resolve<IRepository<Product>>(); Now the exception im gettin System.ArgumentException: GenericArguments[0], 'T', on 'Repository.Infraestructure.Repository`1[T]' violates the constraint of type 'T'. ---> System.TypeLoadException: GenericArguments[0], 'T', on 'Repository.Infraestructure.Repository`1[T]' violates the constraint of type parameter 'T'. If i remove the constraint in the concrete class and the depedency on IObjectSet (if i dont do it get a compile error) everything works FINE, so i dont think is a container issue, but IObjectSet is a MUST in the implementation. Some help with this, please.

    Read the article

  • Are we using IoC effectively?

    - by Juliet
    So my company uses Castle Windsor IoC container, but in a way that feels "off": All the data types are registered in code, not the config file. All data types are hard-coded to use one interface implementation. In fact, for nearly all given interfaces, there is and will only ever be one implementation. All registered data types have a default constructor, so Windsor doesn't instantiate an object graph for any registered types. The people who designed the system insist the IoC container makes the system better. We have 1200+ public classes, so its a big system, the kind where you'd expect to find a framework like Windsor. But I'm still skeptical. Is my company using IoC effectively? Is there an advantage to new'ing objects with Windsor than new'ing objects with the new keyword?

    Read the article

  • How do you install Castle Windsor IOC?

    - by user300266
    I'm currently reading Pro ASP.NET MVC Framework by Sanderson. In the book he recommends setting up IoC using Castle Windsor, and he points out that the download automatically installs it and registers the Castle DLLs in the GAC. Well, at this point in time (5/4/2010), the Castle Project no longer has a downloadable installer that sets this up. Its all broken out into their individual subprojects with the raw files contained in zipped folders. Sadly there's no installation documentation that I can find about how to set it up. Being the noob that I am, I'm stuck and now forced to ask #1 where should castle windsor live on my hard drive? #2 how do I manually register the dlls properly? And, #3 should I be angry at the project maintainers for their oversight? Here's the link: http://www.castleproject.org/castle/download.html

    Read the article

  • FluentNHibernate 1.1 / Castle 1.1 dependency

    - by Innogetics
    I would like to upgrade my FluentNHibernate to version 1.1, but I found out it uses Castle.Core 1.1. I use Castle.Windsor 1.2 in my app which works with Castle.Core 1.2. I now need to find a version of Castle.Windsor that uses this earlier version of Castle.Core, but I can't find it anywhere. What do you recommend I should do? Wait for a version of FluentNHibernate that uses the latest Castle.Core? OR build FluentNHibernate 1.1 from source using the latest Castle.Core? OR downgrade my Castle.Windsor version?

    Read the article

  • Windsor IHandlerSelector in RIA Services Visual Studio 2010 Beta2

    - by Savvas Sopiadis
    Hi everybody! I want to implement multi tenancy using Windsor and i don't know how to handle this situation: i succesfully used this technique in plain ASP.NET MVC projects and thought incorporating in a RIA Services project would be similar. So i used IHandlerSelector, registered some components and wrote an ASP.NET MVC view to verify it works in a plain ASP.NET MVC environment. And it did! Next step was to create a DomainService which got an IRepository injected in the constructor. This service is hosted in the ASP.NET MVC application. And it actually ... works:i can get data out of it to a Silverlight application. Sample snippet: public OrganizationDomainService(IRepository<Culture> cultureRepository) { this.cultureRepository = cultureRepository; } Last step is to see if it works multi-tenant-like: it does not! The weird thing is this: using some line of code and writing debug messages in a log file i verified that the correct handler is selected! BUT this handler seems not to be injected in the DomainService. I ALWAYS get the first handler (that's the logic in my SelectHandler) Can anybody verify this behavior? Is injection not working in RIA Services? Or am i missing something basic?? Development environment: Visual Studio 2010 Beta2 Thanks in advance

    Read the article

  • Wcf Facility Metadata publishing for this service is currently disabled.

    - by cvista
    Hey I'm trying to connect to my Wcf service which is configured using castles wcf facility. When I go to the service in a browser i get: Metadata publishing for this service is currently disabled. Which lists a load of instructions which i cant do because the configuration isnt in the web.config. when I try to connect using VS/add service reference i get: The HTML document does not contain Web service discovery information. Metadata contains a reference that cannot be resolved: 'http://s.ibzstar.com/userservices.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://s.ibzstar.com/userservices.svc. The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. If the service is defined in the current solution, try building the solution and adding the service reference again. Anyone know what I need to do to get this working? The end client is an iPhone app written using Monotouch if that matters - so no castle windsor on the client side. cheers w:// Here's the Windsor.config from the service: <?xml version="1.0" encoding="utf-8" ?> <configuration> <components> <component id="eventServices" service="IbzStar.Domain.IEventServices, IbzStar.Domain" type="IbzStar.Domain.EventServices, IbzStar.Domain" lifestyle="transient"> </component> <component id="userServices" service="IbzStar.Domain.IUserServices, IbzStar.Domain" type="IbzStar.Domain.UserServices, IbzStar.Domain" lifestyle="transient"> </component> The Web.config section: <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <services> </services> <behaviors> <serviceBehaviors> <behavior name="IbzStar.WebServices.Service1Behavior"> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> My App_Start contains this: Container = new WindsorContainer(new XmlInterpreter(new ConfigResource())) .AddFacility<WcfFacility>() .Install(Configuration.FromXmlFile("Windsor.config")); As for the client config - I'm using the wizard to add the service.

    Read the article

  • Hooking into AppInitialize with WCF service

    - by Mark
    Hi, Im having issues with my WCF service. I need to do a windsor container injection pre application_start and noticed i can use the AppInitialise method. It works on visual studio debug but when I deploy to IIS the code does not get fired.. I initialized the class as follows public static class Class1 { public static void AppInitialize() { IWindsorContainer container; container = new WindsorContainer("windsor.xml"); container.AddFacility(); container.Resolve(); } } Is there any special task i need to do to get this to work on IIS. Im using version 6. Thanks!

    Read the article

  • WCF Integration Facility and Self-Hosted Services

    - by IanT8
    I'm self-hosting several services where I do this to register the service: host = new ServiceHost(typeof(MyService)); host.Open(); Behind the scenes, wcf instantiates my service via the default constructor. Is it possble to use the WCF Integration Facility of Castle Windsor to get WCF to call on Windsor to create the service when I am self-hosting? The example seems shows IIS hosted services where the 1st line of the MyService.svc file looks like: <%@ServiceHost language=c# Debug="true" Service="Microsoft.ServiceModel.Samples.CalculatorService" Factory=WindsorServiceHostFactory%> where presumably a factory is used by wcf to instantiate the service instance.

    Read the article

  • Does NInject work in medium trust hosting?

    - by Gabriel
    I'm doing shared hosting with GoDaddy and I developed a sample ASP.NET MVC app using Castle Windsor and unfortunately, it didn't work in a medium trust setting. Specifically, I got this error: "[SecurityException: That assembly does not allow partially trusted callers"... etc. GoDaddy is sadly not flexible in their trust policy. I'm not tied to Windsor and would like to try another one that will work under Medium Trust. I'd actually like to use NInject, but I've read people having mixed success. The only one I've read that works with no problem is Microsoft's Unity. My question is, does NInject work in medium trust? If not, what are my options?

    Read the article

  • Which IOC runs in medium trust

    - by Rippo
    Hi I am trying to get a website running with Mosso that has Castle Windsor as my IOC, however I am getting the following error. [SecurityException: That assembly does not allow partially trusted callers.] GoldMine.WindsorControllerFactory..ctor() in WindsorControllerFactory.cs:33 GoldMine.MvcApplication.Application_Start() in Global.asax.cs:70 My questions are Does Castle Windsor run under medium trust? Can I download the DLL's without having to recompile with nant? (as I don't have this set up and don't know nant at all) Or is there another IOC that I can use that I can download and works in Medium Trust? Thanks

    Read the article

  • Could not find schema information for the element 'castle'.

    - by Richard77
    Hello! I'm creating a Custom tag in my web.config. I first wrote the following entry under the configSections section. <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" /> But, when I try to create a castle node inside the configuration node as below <castle> <components> </components> </castle> I get the following error message:"*Could not find schema information for the element 'castle*'." "*Could not find schema information for the element 'components'***." Am I missing something? I can't find why. And, if I run the application anyway, I get the following error "Could not find section 'Castle' in the configuration file associated with this domain." Ps.// The sample comes from "Pro ASP.NET MVC Framework"/Steven Sanderson/APress ISBN-13 (pbk): 978-1-4302-1007-8" on page 99. Thank you for the help ============================================================ Since I believe to have done exactly what's said in the book and did not succed, I ask the same question in different terms. How do I add a new node using the above information? ============================================================================= Thank you. I did what you said and do not have the two warnings. However, I've go a big new warning: "The element 'configuration' in namespace 'MyWindsorSchema' has invalid child element 'configSections' in namespace 'MyWindsorSchema'. List of possible elements expected: 'include, properties, facilities, components' in namespace 'MyWindsorSchema'."

    Read the article

  • Constructor on type: "Namespace.type" not found.

    - by Nick
    Hello, I am using Castle.Windsor as an IOC. So I am trying to resolve a service type in the constructor of an HTTPHandler. I keep receiving this error, "Constructor on type: "Namespace.type" not found." My configuration has the following entries for service type: IDocumentDirectory <component id="restricted.content.directory" service="org.healthwise.foundations.services.content.IDocumentDirectory, org.healthwise.foundations.services" type="org.healthwise.foundations.services.content.RestrictedLocalizationDocumentDirectory, org.healthwise.foundations.services"> <parameters> <contentDirectory>${content.directory}</contentDirectory> <localizations> <array> <item>en-us</item> <item>es-us</item> </array> </localizations> </parameters> </component> <component id="content.directory" service="org.healthwise.foundations.services.content.IDocumentDirectory, org.healthwise.foundations.services" type="org.healthwise.foundations.services.web.client.WebServiceDocumentDirectory, org.healthwise.foundations.services.web.client"> <parameters> <webServiceURL>#{contentDirectoryWebsiteUrl}</webServiceURL> </parameters> </component> In my new handler the constructor looks like this: public HeartBeatHttpHandler(IDocumentDirectory contentDirectory) { _contentDirectory = contentDirectory; } I have never recieved this error using Castle.Windsor. Can someone explain? Thanks!

    Read the article

  • Good book on Castle Project?

    - by David
    Does anyone know of a good book on the Castle Project? I'm interested in learning more about any of the Castle projects (ActiveRecord, MonoRail, Windsor, anything!) and searches for Castle on Amazon are a little frustrating with the need to weed out all the fiction and nonsense.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >