Unity: The type LogWriter cannot be constructed

后端 未结 5 703
时光取名叫无心
时光取名叫无心 2020-12-20 20:06

For the following \"project\" I am getting a very annoying and inexplicable error when resolving Unity for DI.

InvalidOperationException - The type Lo

5条回答
  •  無奈伤痛
    2020-12-20 20:50

    Try this:

    protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
    
                try
                {
                    IUnityContainer container = new UnityContainer();
                    container.RegisterType();
                    container.RegisterType();
                    container.RegisterType(new InjectionConstructor(typeof(ILogWriter), typeof(ExceptionManager));                    
                    Performance p = container.Resolve();
                }
                catch (Exception ex)
                {
    
                }
            }
    

提交回复
热议问题