내가 SimpleInjector과 Caliburn 마이크로 2.0 이상한 문제가 생겼어요 .... 나는 자원이간단한 인젝터 + Caliburn 마이크로 2.0보기를 해결 오류가
로 설정되어"Cannot locate resource 'views/simpleviewmodel.xaml'."}
말하는 예외를 얻었다
빌드 작업 : 페이지
나는 그것이로드합니다 (.cs를 잃어버린) 자원에 설정하면 ...
는내 부트 스트 래퍼
입니다public class MefBootstrapper : BootstrapperBase
{
public static readonly Container ContainerInstance = new Container();
public MefBootstrapper()
{
Initialize();
}
protected override void Configure()
{
ContainerInstance.Register<IWindowManager, WindowManager>();
ContainerInstance.RegisterSingle<IEventAggregator, EventAggregator>();
ContainerInstance.Register<SimpleViewModel, SimpleViewModel>();
ContainerInstance.Verify();
}
protected override object GetInstance(Type serviceType, string key)
{
return ContainerInstance.GetInstance(serviceType);
}
protected override IEnumerable<object> GetAllInstances(Type serviceType)
{
return ContainerInstance.GetAllInstances(serviceType);
}
protected override void BuildUp(object instance)
{
ContainerInstance.InjectProperties(instance);
}
protected override void OnStartup(object sender, StartupEventArgs e)
{
DisplayRootViewFor<SimpleViewModel>();
}
}
SimpleViewModel는
public class SimpleViewModel : Screen
{
}
정말 간단하고보기는 ... 스스로를 테스트 할뿐만 아니라 내가 uploaded 프로젝트를했습니다
<UserControl x:Class="SimpleInjector.Views.SimpleView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock Text="IT works!" Foreground="Red"></TextBlock> </Grid>
</UserControl>
간단합니다 MefBoostrapper 당신의 경우 부트 스트 래퍼 전체에 댓글을 달고 다른 하나는 주석 처리를 해제하십시오. 그래서 SimpleInjector와 관련된 문제라고 생각합니다.
An y 도움을 주시면 감사하겠습니다. 감사합니다.
Simple Injector 2.6 이상부터는 InjectProperties가 권장되지 않습니다. (https : //simpleinjector.org/depr1). [this q/a] (https://stackoverflow.com/questions/25970820/caliburn-micro-and-simple-injector-injectproperties-is-deprecated-how-to-bui) – Steven