5

我正在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.2to3.1.1Caliburn.Microfrom 1.5.1to更新1.5.2(通过使用Nuget Package Manager)。之后,我无法运行该项目。我收到此错误:

'对匹配指定绑定约束的'MyAppBootstrapper'类型的构造函数的调用引发了异常。行号“9”和行位置“22”。

在这一行App.xaml

内部异常消息是:

{“找不到方法:'Void Caliburn.Micro.Bootstrapper`1..ctor(Boolean)'。”}

我错过的升级有什么意义吗?

完整的堆栈跟踪:

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
4

1 回答 1

9

好吧,我找到了答案:) 问题出在这里:

Caliburn.Micro.Autofac nuget包(version="1.5.0"Caliburn.Micro.Autofac.AutofacBootstrapper<TRootViewModel> )在Caliburn.Micro包中扩展,并具有如下构造函数:Caliburn.Micro.Bootstrapper<TRootModel>

public AutofacBootstrapper() : base(true) { }

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

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

而在 version 中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,这很容易通过参考原始文件(此处)或阅读 nuget 包源来实现。另外,如果您需要,是我重新实现的一个。

于 2013-08-19T18:46:41.770 回答