2013-07-05 16 views
1

我有现有的代码:从卡利科技更新1.4〜1.5 - > IoC.Get <>不与懒惰的工作<>是编译和运行良好与卡利微型1.4了

private static readonly Lazy<IShell> shellLazy = new Lazy<IShell>(IoC.Get<IShell>, true); 

我删除了1.4版本和安装通过NuGet的1.5版本,并没有改变任何东西这一行现在抛出一个错误:

错误1'System.Lazy.Lazy(System.Func,System.Threading.LazyThreadSafetyMode)'的最佳重载方法匹配一些无效参数C:\ Users \ User \ Documents \ Visual Studio 2012 \ Projects \ Arnova \ Src \ CShellCore \ Shell.cs 35 58 CShellCore

我已经找到摆脱这种错误的唯一方法是在所有避免使用懒惰<>:

private static readonly IShell shellLazy = IoC.Get<IShell>(); 

...我已经寻找相关IoC.Get <>和懒惰<>,什么东西可能已经从版本1.4更改为1.5,并且无法找到任何解释Caliburn Micro在这些版本之间发生了哪些变化以及如何解决此问题的内容。

+0

版本v4.0.30319 – Darren

回答

0

我觉得你的问题是,IoC.Get<T>static方法返回T类型的实例,换句话说,它一个Func<T>所以要解决这个问题,你将不得不修改像这样的代码:

private static readonly Lazy<IShell> shellLazy = new Lazy<IShell>(() => IoC.Get<IShell>(), true); 

这是编译错误,有关于Lazy<>类型没有构造函数接受一个IShell实例的原因。

+0

由于这个工作。 – Darren

0

发现它,不知道为什么这需要改变这种方式?智能感知显示1.4和1.5 caliburn微版本的相同信息,这些功能看起来是期待相同的参数。

这似乎到目前为止,虽然工作:

private static readonly Lazy<IShell> shellLazy = new Lazy<IShell>(() => { return IoC.Get<IShell>(); }, true); 
相关问题