castle-windsor

Why is CastleWindsor's BeginScope out of scope?

空扰寡人 提交于 2019-12-04 02:39:38
I'm trying to add Castle Windsor to my Web API project, and am following this post , but am getting a compile-time error on this line of code: this._scope = container.BeginScope(); ...as " 'Castle.Windsor.IWindsorContainer' does not contain a definition for 'BeginScope' and no extension method 'BeginScope' accepting a first argument of type 'Castle.Windsor.IWindsorContainer' could be found (are you missing a using directive or an assembly reference?) " Here is the entire code so that it can be seen in context: using System; using System.Collections.Generic; using System.Linq; using System.Web;

How to use Castle.Windsor in an assembly loaded using reflection

最后都变了- 提交于 2019-12-03 22:55:35
问题 Let's say I have a library Lib.dll, which uses Castle.Windsor to initialize its services. I have a main application App.exe, which loads Lib.dll on runtime using reflection. App.exe does not know the location of Lib.dll beforehand, it is only known at runtime. In this case, when App.exe loads Lib.dll and Lib.dll initialize its services, a System.TypeInitializationException exception is thrown, because Castle.Windsor cannot find the service type. Castle.MicroKernel.SubSystems.Conversion

Specifying instance for registration of a component with Castle Windsor

做~自己de王妃 提交于 2019-12-03 22:39:29
I have what is probably a simple question here about Castle Windsor, which I haven't been using for very long. I'm trying to register a service with a specific instance that will be the singleton implementation of the service. The container cannot try to create the implementation of the service itself because it has dependencies that the container will not be able to resolve. I have an instance of the service and I want that to be the one and only instance used for anyone requesting the service. But I appear to be having very little luck. I momentarily had hopes raised by using this code:

How to reuse a transient dependency in same context with Castle Windsor DI container

允我心安 提交于 2019-12-03 21:41:10
If I have the following setup, how can I configure my container to use the same database, when objects are created in the same context public class Database { } public interface IRepository { Database Database { get; } } public interface IFooRepository : IRepository { } public interface IBarRepository : IRepository { } public class FooRepository : IFooRepository { public Database Database { get; private set; } public FooRepository(Database database) { this.Database = database; } } public class BarRepository : IBarRepository { public Database Database { get; private set; } public BarRepository

Nhibernate, WinForms, Castle Windsor: Session Management

不羁的心 提交于 2019-12-03 21:15:52
I know the question of session management has been brought up in the past, but I could not find anything that helps me overcome my problem.. I have a number of repository classes (e.g CustomerRepository, ProductRepository etc.) which I resolve through Castle Windsor (Note: I am trying to apply the three calls pattern as outlined here ). I figure I'd best have a session per Presenter (in my case, this is equivalent to one per form), however, the repository classes need to access the session for the currently active form.. I am not sure how I incorporate this with the fact that these

I am looking for a simple yet practical and robust IOC/DI framework for .net

那年仲夏 提交于 2019-12-03 20:50:43
I am going to use it in a project with less-experienced developers so a complex framework such as Spring.NET is not an option. I was thinking about: Ninject Castle Windsor StructureMap Which would present a moderate learning curve without losing flexibility? and another question - where is the correct place to put the configuration? Since the kernel/configuration on a 3-tier ASP.NET application (not MVC!!! all examples are using MVC :) ) Mark Seemann The great thing about proper use of DI is that you can defer the decision about which DI Container to use until the last responsible moment . In

Castle Windsor: How to specify a constructor parameter from code?

末鹿安然 提交于 2019-12-03 19:12:53
问题 Say I have the following class MyComponent : IMyComponent { public MyComponent(int start_at) {...} } I can register an instance of it with castle windsor via xml as follows <component id="sample" service="NS.IMyComponent, WindsorSample" type="NS.MyComponent, WindsorSample"> <parameters> <start_at>1</start_at > </parameters> </component> How would I go about doing the exact same thing but in code? (Notice, the constructor parameter) 回答1: Edit: Used the answers below code with the Fluent

Memory Leaks when using Entity Framework and Windsor in an ASP.NET MVC application

蹲街弑〆低调 提交于 2019-12-03 17:14:27
I'm having trouble getting the windsor container and entity framework working together and it may be due to a problem I've introduced myself but the net result is that I'm getting a terrible memory leaks caused. I have my application set up with an EDMX and Repositories and Services and those and the objectcontext are set to perwebrequest in the windsor configuration file I use. However when I look at the memory usage in ANTS memory profiler I see that the object context cache is still being held onto as a reference with the cache despite confirming that Dispose has been called. And each

Windsor Container: How to force dispose of an object?

China☆狼群 提交于 2019-12-03 17:04:53
问题 I have an object that implements IDisposable that is registered with the Windsor Container and I would like to dispose of it so it's Dispose method is called and next time Resolve is called it fetches a new instance. Does container.Release(obj); automatically call Dispose() immediately? Or do I need to do obj.Dispose(); container.Release(obj); Couldn't find anything in the documentation on what exactly Release does EDIT: See my answer below for the results of tests I ran. Now the question

Castle Windsor/DelegatingHandler/IPrincipal Dependency Injection (DI)/Inversion of Control (IoC) in ASP.NET Web API

人走茶凉 提交于 2019-12-03 16:20:52
I decided to clean this post up and I posted a sample project at ge.tt/3EwoZEd/v/0?c Spent around 30 hours on this already and still can't figure it out... help would be really appreciated! I have an ASP.NET Web API solution that uses this code: http://www.piotrwalat.net/basic-http-authentication-in-asp-net-web-api-using-message-handlers/ to implement "Basic HTTP authentication in ASP.NET Web API using Message Handlers". I'm new to IoC/DI and I'm trying to get this to work with Castle Windsor. I've been trying a lot of different things but I get 1 of the following errors depending on what I