0

IViewFactory 인터페이스를 사용하여 뷰를 부트 스트랩하기 위해 MVVM 및 Caliburn을 사용중인 WPF 응용 프로그램 (.NET 4.5)에서 작업하고 있습니다.
내 ViewModels 중 하나 (QuestionRadioBtnViewModel)를 제외한 모든 항목이 초기화되는 특이한 문제가 발생했습니다. 런타임에
내가 ViewModel에WPF Caliburn IViewFactory가 생성자를 찾지 못했습니다. - 'Castle.MicroKernel.Resolvers.DependencyResolverException'

var questionRadBtnVm = _viewFactory.CreateQuestionRadioBtnViewModel(answer.Text); 

오류 메시지를 초기화하려고 할 때하면 다시 온다 :

A first chance exception of type 'Castle.MicroKernel.Resolvers.DependencyResolverException' occurred in Castle.Windsor.dll 

Additional information: Could not resolve non-optional dependency for 'Corp.Conveyancing.Desktop.ViewModels.Question.QuestionRadioBtnViewModel' (Corp.Conveyancing.Desktop.ViewModels.Question.QuestionRadioBtnViewModel). Parameter 'stringValue' type 'System.String' 

그러나 방법 서명이 잘 생성자를 일치합니다.

IViewFactory :

public interface IViewFactory 
{ 
    QuestionRadioBtnViewModel CreateQuestionRadioBtnViewModel(string textValue); 
} 

QuestionRadioBtnViewModel

public QuestionRadioBtnViewModel(IEventAggregator eventAggregator, string stringValue) 
{ 
    _stringValue = stringValue; 
    _eventAggregator = eventAggregator; 
} 

Caliburn Bootstraper

public class ReactiveBootstrapper : BootstrapperBase 
{ 
    public ReactiveBootstrapper() 
    { 
     Log.Info("Starting bootstrapper"); 
     Start(); 
    } 

    protected override void OnStartup(object sender, StartupEventArgs e) 
    { 
     DisplayRootViewFor(typeof(MainViewModel)); 
    } 

    protected override void BuildUp(object instance) 
    { 
     Container.BuildUp(instance); 
    } 

    protected override void Configure() 
    { 
     Container = new ApplicationContainer(); 

     Container.RegisterViewModels(typeof(MainViewModel)); 

     SetXamlLanguage(); 
     Container.Install(FromAssembly.Containing<IObjectModelFactory>()); 
     Container.AddFacility<LoggingFacility>(f => f.UseLog4Net(Assembly.GetEntryAssembly().GetName().Name + ".exe.log4net")); 
     Container.AddFacility<TypedFactoryFacility>(); 
     Container.Register(Component.For<IViewFactory>().AsFactory()); 
     Container.Register(Component.For<IServerOperations>().ImplementedBy<ServerOperations>()); 
     Container.Register(Component.For<IQuestionControlFactory>().ImplementedBy<QuestionControlFactory>()); 
     Container.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero); 

     RegisterWcfServices(); 

     Container.Register(Component.For<IQasManager>().ImplementedBy<QasWebManager>().DependsOn(Dependency.OnValue("url", Settings.Default.QasUrl))); 
    } 

    protected override IEnumerable<object> GetAllInstances(Type service) 
    { 
     return Container.ResolveAll(service).Cast<object>(); 
    } 

    protected override IEnumerable<Assembly> SelectAssemblies() 
    { 
     return new[] { 
      Assembly.GetExecutingAssembly(), 
      typeof(MainViewModel).Assembly, 
      typeof(MessageViewModel).Assembly 
     }; 
    } 

    protected override object GetInstance(Type service, string key) 
    { 
     if (string.IsNullOrWhiteSpace(key)) 
     { 
      return Container.Resolve(service); 
     } 
     return Container.Resolve(key, service); 
    } 
} 

IViewFactory 잘 작동을 사용하고 데이터가 아무 문제가 전달되지되고 다른 모든 생성자. 나는 여기서 명백한 무엇인가를 놓치고 있어야 할까?

답변

0

나 자신을 발견했습니다.
그것은뿐만 아니라 방법의 서명이 일치해야 밝혀 있지만, 매개 변수도 이름은

public QuestionRadioBtnViewModel(IEventAggregator eventAggregator, string stringValue) 

stringValue 텍스트가 일치해야 통과된다.

public interface IViewFactory 
{ 
    QuestionRadioBtnViewModel CreateQuestionRadioBtnViewModel(string stringValue); 
}