Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用WinsdorContainer初始化类型时出现问题 公共应用程序视图(字符串[]args) { 初始化组件(); 字符串configFilePath=Path.Combine(AppDomain.CurrentDomain.BaseDirectory,“log4net.config”); FileInfo configFileInfo=新文件信息(configFilePath); ConfigureAndWatch(configFileInfo); IConfigurationSource configSource=ConfigurationManager.GetSection(“ActiveRecord”)作为IConfigurationSource; Assembly=Assembly.Load(“Danel.Nursing.Model”); ActiveRecordStarter.Initialize(程序集,配置源); WindsorContainer WindsorContainer=ApplicationUtils.GetWindsorContainer(); windsorContainer.Kernel.AddComponentInstance(this); windsorContainer.Kernel.AddComponent(typeof(ApplicationController).Name,typeof(ApplicationController)); controller=windsorContainer.Resolve();//此处引发异常 OnApplicationLoad(args); }_C#_Castle Windsor - Fatal编程技术网

C# 使用WinsdorContainer初始化类型时出现问题 公共应用程序视图(字符串[]args) { 初始化组件(); 字符串configFilePath=Path.Combine(AppDomain.CurrentDomain.BaseDirectory,“log4net.config”); FileInfo configFileInfo=新文件信息(configFilePath); ConfigureAndWatch(configFileInfo); IConfigurationSource configSource=ConfigurationManager.GetSection(“ActiveRecord”)作为IConfigurationSource; Assembly=Assembly.Load(“Danel.Nursing.Model”); ActiveRecordStarter.Initialize(程序集,配置源); WindsorContainer WindsorContainer=ApplicationUtils.GetWindsorContainer(); windsorContainer.Kernel.AddComponentInstance(this); windsorContainer.Kernel.AddComponent(typeof(ApplicationController).Name,typeof(ApplicationController)); controller=windsorContainer.Resolve();//此处引发异常 OnApplicationLoad(args); }

C# 使用WinsdorContainer初始化类型时出现问题 公共应用程序视图(字符串[]args) { 初始化组件(); 字符串configFilePath=Path.Combine(AppDomain.CurrentDomain.BaseDirectory,“log4net.config”); FileInfo configFileInfo=新文件信息(configFilePath); ConfigureAndWatch(configFileInfo); IConfigurationSource configSource=ConfigurationManager.GetSection(“ActiveRecord”)作为IConfigurationSource; Assembly=Assembly.Load(“Danel.Nursing.Model”); ActiveRecordStarter.Initialize(程序集,配置源); WindsorContainer WindsorContainer=ApplicationUtils.GetWindsorContainer(); windsorContainer.Kernel.AddComponentInstance(this); windsorContainer.Kernel.AddComponent(typeof(ApplicationController).Name,typeof(ApplicationController)); controller=windsorContainer.Resolve();//此处引发异常 OnApplicationLoad(args); },c#,castle-windsor,C#,Castle Windsor,堆栈跟踪如下所示: Castle.MicroKernel.ComponentActivator.ComponentActivator异常 未经处理 Message=“ComponentActivator:无法 实例化 Danel.护理.日程安排.操作.数据服务.NurseAbsenceDataService“ Source=“Castle.MicroKernel” 堆栈跟踪: 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActi

堆栈跟踪如下所示:

Castle.MicroKernel.ComponentActivator.ComponentActivator异常 未经处理
Message=“ComponentActivator:无法 实例化 Danel.护理.日程安排.操作.数据服务.NurseAbsenceDataService“ Source=“Castle.MicroKernel”
堆栈跟踪: 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext 上下文,对象[]参数,类型[] (签名) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext (上下文) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext (上下文) 在Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext (上下文) 在Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext (上下文) 在Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext (上下文) 位于Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext (上下文) 位于Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveServiceDependency(CreationContext 上下文,组件模型, 依赖项(模型依赖项) 位于Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext 上下文,ISubDependencyResolver parentResolver,组件模型, 依赖项(模型依赖项) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate 构造函数,CreationContext上下文, 键入[]和签名) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext (上下文) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext (上下文) 在Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext (上下文) 在Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext (上下文) 在Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext (上下文) 位于Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext (上下文) 位于Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveServiceDependency(CreationContext 上下文,组件模型, 依赖项(模型依赖项) 位于Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext 上下文,ISubDependencyResolver parentResolver,组件模型, 依赖项(模型依赖项) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate 构造函数,CreationContext上下文, 键入[]和签名) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext (上下文) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext (上下文) 在Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext (上下文) 在Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext (上下文) 在Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext (上下文) 位于Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext (上下文) 位于Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveServiceDependency(CreationContext 上下文,组件模型, 依赖项(模型依赖项) 位于Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext 上下文,ISubDependencyResolver parentResolver,组件模型, 依赖项(模型依赖项) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate 构造函数,CreationContext上下文, 键入[]和签名) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext (上下文) 位于Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext (上下文) 在Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext (上下文) 在Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext (上下文) 在Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext (上下文) 位于Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext (上下文) 位于Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler 处理程序,类型服务,IDictionary 附加参数) 位于Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler 处理程序,类型(服务) 在Castle.MicroKernel.DefaultKernel.get_项(键入 服务) 在温莎城堡
    public ApplicationView(string[] args)
    {
        InitializeComponent();

        string configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config");
        FileInfo configFileInfo = new FileInfo(configFilePath);
        XmlConfigurator.ConfigureAndWatch(configFileInfo);

        IConfigurationSource configSource = ConfigurationManager.GetSection("ActiveRecord") as IConfigurationSource;
        Assembly assembly = Assembly.Load("Danel.Nursing.Model");
        ActiveRecordStarter.Initialize(assembly, configSource);         

        WindsorContainer windsorContainer = ApplicationUtils.GetWindsorContainer();
        windsorContainer.Kernel.AddComponentInstance<ApplicationView>(this);
        windsorContainer.Kernel.AddComponent(typeof(ApplicationController).Name, typeof(ApplicationController));
        controller = windsorContainer.Resolve<ApplicationController>(); // exception is thrown here

        OnApplicationLoad(args);
    }
   namespace Danel.Nursing.Scheduling.Actions.DataServices
    {
        using System;
        using Helpers;
        using Rhino.Commons;
        using Danel.Nursing.Model;
        using NHibernate.Expressions;
        using System.Collections.Generic;
        using DateUtil = Danel.Nursing.Scheduling.Actions.Helpers.DateUtil;
        using Danel.Nursing.Scheduling.Actions.DataServices.Interfaces;

        public class NurseAbsenceDataService : AbstractDataService<NurseAbsence>, INurseAbsenceDataService
        {
            NurseAbsenceDataService(IRepository<NurseAbsence> repository)
                : base(repository)
            {
            }

            //...
        }
    }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Danel.Nursing.Scheduling.Actions.Interfaces;
using Rhino.Commons;
using System.Reflection;
using Castle.Windsor;

namespace Danel.Nursing.Scheduling.Actions.Helpers
{
    public class DataServicesInitiator : IDataServicesInitiator
    {
        public void AddToIocContainer(ref WindsorContainer windsorContainer)
        {
            if (windsorContainer.Kernel.HasComponent(typeof(IRepository<>)) == false)
                windsorContainer.AddComponent(typeof(ARRepository<>).FullName, typeof(IRepository<>), typeof(ARRepository<>));
            foreach (Type type in Assembly.Load("Danel.Nursing.Scheduling.Actions").GetTypes())
            {
                if (type == null)
                    continue;

                if (type.Namespace != "Danel.Nursing.Scheduling.Actions.DataServices")
                    continue;

                if (type.IsAbstract || type.IsInterface)
                    continue;

                if (windsorContainer.Kernel.HasComponent(type.FullName))
                    continue;

                if (type.GetInterfaces().Length == 0)
                    windsorContainer.AddComponent(type.FullName, type);
                else
                    windsorContainer.AddComponent(type.FullName, type.GetInterfaces()[0], type);
            }
        }
    }
}