找不到方法:'Void Caliburn.Micro.Bootstrapper`1..ctor(布尔)'

时间:2013-08-19 16:10:25

标签: wpf autofac caliburn.micro wpf-4.0

我正在使用这些软件包开展WPF项目:

<package id="Autofac" version="3.0.2" targetFramework="net40" />
<package id="Caliburn.Micro" version="1.5.1" targetFramework="net40" />
<package id="Caliburn.Micro.Autofac" version="1.5.0" targetFramework="net40" />

直到昨天我将软件包更新为:

<package id="Autofac" version="3.1.1" targetFramework="net40" />
<package id="Caliburn.Micro" version="1.5.2" targetFramework="net40" />
<package id="Caliburn.Micro.Autofac" version="1.5.0" targetFramework="net40" />

我的意思是,我将Autofac3.0.2更新为3.1.1,将Caliburn.Micro1.5.1更新为1.5.2(使用Nuget Package Manager })。在那之后,我无法运行该项目。我收到这个错误:

  

'在类型'MyAppBootstrapper'上调用构造函数   匹配指定的绑定约束引发异常。线   数字'9'和行位置'22'。

App.xaml的这一行:

  

内部异常消息是:

  

{“未找到方法:'无效   Caliburn.Micro.Bootstrapper`1..ctor(布尔型)”。“}

我错过了升级是否有任何意义?

完整的堆栈跟踪:

at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Shivar.Tameshk.Server.UI.App.InitializeComponent() in d:\Projects\Shivar.Tameshk\Tameshk\Server\Shivar.Tameshk.Server.UI\App.xaml:line 1
at Shivar.Tameshk.Server.UI.App.Main() in d:\Projects\Shivar.Tameshk\Tameshk\Server\Shivar.Tameshk.Server.UI\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

和内部异常的堆栈:

at Caliburn.Micro.Autofac.AutofacBootstrapper`1..ctor()
at Shivar.Tameshk.Server.UI.ServerUiBootstrapper..ctor() in d:\Projects\Shivar.Tameshk\Tameshk\Server\Shivar.Tameshk.Server.UI\ServerUiBootstrapper.cs:line 28

1 个答案:

答案 0 :(得分:9)

好吧,我找到了答案:)问题在于:

Caliburn.Micro.Autofac nuget包中的Caliburn.Micro.Autofac.AutofacBootstrapper<TRootViewModel> version =“1.5.0”)在中扩展Caliburn.Micro.Bootstrapper<TRootModel> Caliburn.Micro 包,并有一个像这样的构造函数:

public AutofacBootstrapper() : base(true) { }

这意味着它通过传递base.ctor参数(boolean)来调用base.ctor(bool)。事情就是这样。版本Caliburn.Micro.Bootstrapper<TRootModel>中的1.5.1包含一个bool参数的构造函数:

public Bootstrapper(bool useApplication = true) : base(useApplication) {
  this.Start();
}

在版本1.5.2中,它只有一个无参数构造函数:

public Bootstrapper() : base(true) {
  this.Start();
}

以下是签名:

// Assembly: Caliburn.Micro.Autofac, Version=1.5.0.0
namespace Caliburn.Micro.Autofac {
    public class AutofacBootstrapper<TRootViewModel> : Bootstrapper<TRootViewModel> {
        public AutofacBootstrapper() : base(true) { }
    }
}

// Assembly: Caliburn.Micro, Version=1.5.1.0
namespace Caliburn.Micro {
    public class Bootstrapper<TRootModel> : BootstrapperBase {
        public Bootstrapper(bool useApplication = true) : base(useApplication) {
            this.Start();
        }
    }
}

// Assembly: Caliburn.Micro, Version=1.5.2.0
namespace Caliburn.Micro {
    public class Bootstrapper<TRootModel> : BootstrapperBase {
        public Bootstrapper() : base(true) {
            this.Start();
        }
    }
}

因此,Caliburn.Micro.Autofac, Version=1.5.0.0无法与Caliburn.Micro, Version=1.5.2.0一起使用,您必须创建自己的AutofacBootstrapper,这很容易通过引用原始{{1}}来实现或阅读nuget包源。此外,here是我重新实施的,如果您需要的话。