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);
}
Трассировка стека такова:
Castle.MicroKernel.ComponentActivator.ComponentActivatorException
был необработан
Сообщение = "ComponentActivator: не удалось
иллюстрировать примерами
Danel.Nursing.Scheduling.Actions.DataServices.NurseAbsenceDataService»
Источник = "Castle.MicroKernel"
Трассировки стека:
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance (CreationContext
контекст, аргументы объекта [], тип []
подпись)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate (CreationContext
контекст)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate (CreationContext
контекст)
at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create (CreationContext
контекст)
at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve (CreationContext
контекст)
at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve (CreationContext
контекст)
в Castle.MicroKernel.Handlers.DefaultHandler.Resolve (CreationContext
контекст)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveServiceDependency (CreationContext
контекст, модель ComponentModel,
DependencyModel зависимость)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve (CreationContext
контекст, ISubDependencyResolver
parentResolver, модель ComponentModel,
DependencyModel зависимость)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments (ConstructorCandidate
конструктор, контекст CreationContext,
Тип [] и подпись)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate (CreationContext
контекст)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate (CreationContext
контекст)
at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create (CreationContext
контекст)
at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve (CreationContext
контекст)
at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve (CreationContext
контекст)
в Castle.MicroKernel.Handlers.DefaultHandler.Resolve (CreationContext
контекст)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveServiceDependency (CreationContext
контекст, модель ComponentModel,
DependencyModel зависимость)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve (CreationContext
контекст, ISubDependencyResolver
parentResolver, модель ComponentModel,
DependencyModel зависимость)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments (ConstructorCandidate
конструктор, контекст CreationContext,
Тип [] и подпись)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate (CreationContext
контекст)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate (CreationContext
контекст)
at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create (CreationContext
контекст)
at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve (CreationContext
контекст)
at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve (CreationContext
контекст)
в Castle.MicroKernel.Handlers.DefaultHandler.Resolve (CreationContext
контекст)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveServiceDependency (CreationContext
контекст, модель ComponentModel,
DependencyModel зависимость)
at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve (CreationContext
контекст, ISubDependencyResolver
parentResolver, модель ComponentModel,
DependencyModel зависимость)at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments (ConstructorCandidate
конструктор, контекст CreationContext,
Тип [] и подпись)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate (CreationContext
контекст)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate (CreationContext
контекст)
at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create (CreationContext
контекст)
at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve (CreationContext
контекст)
at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve (CreationContext
контекст)
в Castle.MicroKernel.Handlers.DefaultHandler.Resolve (CreationContext
контекст)
at Castle.MicroKernel.DefaultKernel.ResolveComponent (IHandler
обработчик, служба типа, IDictionary
additionalArguments)
at Castle.MicroKernel.DefaultKernel.ResolveComponent (IHandler
обработчик, тип обслуживания)
at Castle.MicroKernel.DefaultKernel.get_Item (Тип
оказание услуг)
в Castle.Windsor.WindsorContainer.Resolve (Тип
оказание услуг)
в Castle.Windsor.WindsorContainer.ResolveT
в Danel.Nursing.Scheduling.ApplicationView..ctor (String []
args) в
E: \ Agile \ Планирование \ Danel.Nursing.Scheduling \ ApplicationView.cs: линия
65
в Danel.Nursing.Scheduling.Program.Main (String []
args) в
E: \ Проворной \ Планирование \ Danel.Nursing.Scheduling \ Program.cs: линия
24
в System.AppDomain._nExecuteAssembly (Assembly
сборка, строка [] args)
в System.AppDomain.ExecuteAssembly (String
AssemblyFile, Доказательства
AssemblySecurity, String [] args)
в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly ()
в System.Threading.ThreadHelper.ThreadStart_Context (Object
государство)
в System.Threading.ExecutionContext.Run (ExecutionContext
executeContext, ContextCallback
обратный вызов, состояние объекта)
в System.Threading.ThreadHelper.ThreadStart ()
InnerException:
System.ArgumentNullException
Сообщение = "Значение не может быть нулевым. \ R \ nИмя параметра: типы"
Источник = "mscorlib"
ParamName = "типы"
Трассировки стека:
в System.Type.GetConstructor (BindingFlags
bindingAttr, Binder binder, Тип []
типы, модификаторы ParameterModifier [])
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.FastCreateInstance (Тип
implType, Object [] arguments, Type []
подпись)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance (CreationContext
контекст, аргументы объекта [], тип []
подпись)
InnerException:
Это на самом деле говорит, что тип, который я пытаюсь инициализировать, не существует, я думаю.
Это конкретный тип, на который он жалуется:
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)
{
}
//...
}
}
AbstractDataService пока содержит только IRepository.
Кто-нибудь понял, почему выдается исключение?
EDIT:
Проблема лежит здесь:
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);
}
}
}
}
По какой-то причине тип равен null, хотя GetTypes не возвращает нулевые типы.