unity-container

Unity(3.5) Interception Not Working in MVC

旧城冷巷雨未停 提交于 2019-12-12 03:16:53
问题 I am trying to incorporate Interception using PolicyInjectionBehavior and get the this error: Exception information: Exception type: ResolutionFailedException Exception message: Resolution of the dependency failed, type = "CSR.Presentation.Controllers.HomeController", name = "(none)". Exception occurred while: Calling constructor Microsoft.Practices.Unity.InterceptionExtension.PolicyInjectionBehavior(Microsoft.Practices.Unity.InterceptionExtension.CurrentInterceptionRequest

which one is better structure map or unity application block

不想你离开。 提交于 2019-12-12 02:55:54
问题 I want to use dependancy injection technique in my site. For that i want to choose either structuremap or unity application block. So which one is better and why we should use one of them? 回答1: There's a whole discussion on the two in this question. 来源: https://stackoverflow.com/questions/1398486/which-one-is-better-structure-map-or-unity-application-block

Unity error while loading configuration: The type ObjectContext has multiple constructors of length 1. Unable to disambiguate

会有一股神秘感。 提交于 2019-12-12 02:47:46
问题 Hell o, I have a problem to register a repository with unity container. I have a following configuration and classes: /* Generic repository: */ public class Repository<E> : IRepository<E> where E : EntityObject { private readonly ObjectContext _ctx; public ObjectContext Context { get { return _ctx; } } public Repository(ObjectContext context) { _ctx = context; } } /* Concrete repository: */ public class SourceRepository : Repository<Source> { public SourceRepository(EntityContext context) :

Can't resolve types from unity config file

守給你的承諾、 提交于 2019-12-12 02:15:02
问题 Trying to set up Unity via XML configurations I'm getting this exception The type name or alias ServiceHost could not be resolved. Please check your configuration file and verify this type name. Trying to comment that out I get the same exception for the next and then the next after that so the problem must lie somewhere in my setup. <unity> <typeAliases> <!-- Lifetime manager types --> <typeAlias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft

Registration by convention and interception causes ResolutionFailedException

非 Y 不嫁゛ 提交于 2019-12-12 01:49:10
问题 Simple scenario public interface IFoo { int GetData(); } public class Foo : IFoo { [CacheResult] public int GetData() { .... } } public class MyController { [Dependency] IFoo Foo {get; set;} } If I register the interface manually, resolving MyController works fine: container.RegisterType<IFoo, Foo>(new ContainerControlledLifetimeManager(), new InterceptionBehavior<PolicyInjectionBehavior>(), new Interceptor<InterfaceInterceptor>()); var controller = container.Resolve<MyController>(); If I try

How to show ui elements on top Unity

情到浓时终转凉″ 提交于 2019-12-12 01:48:43
问题 how can I show my ui elements on top of the others ? http://prntscr.com/brjccg you can see the right side of the panel but the left one is under the map object. How can fix that i want to see both sides of it ? Here's the components it currently has on http://prntscr.com/brjdab 回答1: Unity renders UI from top to bottom. Anything you want on top should be placed at last in hierarchy. This only works with UI elements. To change rendering order between 2D Sprite Objects and UI elements e.g Canvas

Unity fails to load generic type definition via xml configuration

吃可爱长大的小学妹 提交于 2019-12-12 01:26:32
问题 I'm running into some problems configuring Unity 3.0 via XML configuration. Resolving the generic type will give me the following exception message: The type INLog`1 does not have an accessible constructor. Here's the layout for my logging classes: namespace Common.Utils.Logging { public interface INLog { } public interface INLog<T> : INLog where T : class { } public class NLog : INLog { public NLog(Type type) { } } public class NLog<T> : NLog, INLog<T> where T : class { public NLog() : base

Unity Xml configuration for Nhibernate IsessionFactory

时光毁灭记忆、已成空白 提交于 2019-12-12 01:23:09
问题 I resolved session factory using code as UnityContainer.RegisterInstance(typeof(ISessionFactory), new NHibernate.Cfg.Configuration().Configure().BuildSessionFactory()); My service which defines property as public class myService { [Dependency] public ISessionFactory SessionFactory{get;set;} } But don't know how to configure this using XML configuration of unity 2. 回答1: Disclaimer, this answer is more related to the content discussed in here https://stackoverflow.com/a/29730411/1679310

Cannot convert lambda expression to type 'InjectionMember[]' because it is not a delegate type. - How can use DI in MVC application [duplicate]

我只是一个虾纸丫 提交于 2019-12-12 00:47:55
问题 This question already has answers here : How to create objects using a static factory method? (2 answers) Closed last year . I have written asp.net core application and used below code for dependency injection, which is working fine as expected. services.AddScoped<IDeviceRepository<Device>>(factory => { return new DeviceRepository<Device>( new AzureTableSettings( storageAccount: Configuration.GetConnectionString("Table_StorageAccount"), storageKey: Configuration.GetConnectionString("Table

Hot to register already constructed instance in unity?

你。 提交于 2019-12-12 00:38:21
问题 I'm try to construct HttpClient before register it in unity, but it fails at runtime with error message says HttpMessageHandler not accessible. HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:3721"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); IUnityContainer container = new UnityContainer(); container.RegisterInstance<HttpClient>(client); IUnityContainer newcontainer = new UnityContainer(); HttpClient