WindowsManager.ShowDialog only has 2 parameters

Topics: Getting Started, UI Architecture
Nov 1, 2011 at 3:54 AM


I'm writing a WPF app using Caliburn.Micro v1.2. I'm trying to use the window manager to show a modal dialog and pass in some settings to remove the maximize button but the ShowDialog method is only allowing 2 parameter. It is also telling me that ShowPopup is invalid. 

 I have looked at the source code and can see both show popup and show dialog with 3 parameters. How am I using the wrong version of windows manager?

I am doing this using a bootstrapper copied from the examples:

    public class Bootstrapper : Bootstrapper<IShell>
        private CompositionContainer _container;

        protected override void Configure()
            _container = new CompositionContainer(
                new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)))

            var batch = new CompositionBatch();

            batch.AddExportedValue<IWindowManager>(new WindowManager());
            batch.AddExportedValue<IEventAggregator>(new EventAggregator());


        protected override object GetInstance(Type serviceType, string key)
            string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key;
            var exports = _container.GetExportedValues<object>(contract);

            if (exports.Count() > 0)
                return exports.First();

            throw new Exception(string.Format("Could not locate any instances of contract {0}.", contract));

        protected override IEnumerable<object> GetAllInstances(Type serviceType)
            return _container.GetExportedValues<object>(AttributedModelServices.GetContractName(serviceType));

        protected override void BuildUp(object instance)

Any ideas what I'm doing wrong?



Nov 2, 2011 at 8:43 PM

Anyone? You can replicate this using the HelloWindowManager example.

Here is the Caliburn source for WindowManager showing the 3rd param:

    public interface IWindowManager
        /// <summary>
        /// Shows a modal dialog for the specified model.
        /// </summary>
        /// <param name="rootModel">The root model.</param>
        /// <param name="context">The context.</param>
        /// <param name="settings">The optional dialog settings.</param>
        /// <returns>The dialog result.</returns>
        bool? ShowDialog(object rootModel, object context = null, IDictionary<string, object> settings = null);

This is under Caliburn.Micro.WPF.

How am I referencing an interface with only 2 parameters?



Nov 2, 2011 at 10:02 PM

Double check your project reference. It seems there is a mismatch between the assembly you are using as a reference and the one used to compile your project. Any chance that the project is not being built? Check the solution Configuration to ensure that everything is ok. 

Nov 2, 2011 at 10:11 PM

I'm using Nuget to reference Caliburn. The code is from the source. 

Nov 2, 2011 at 10:17 PM

There is definitely an assembly version conflict. Maybe the project is not referencing the same assembly retrieved through NuGet? I don't use it (I prefer to keep CM up-to-date manually), so I cannot be sure, but the version with 2 parameters was available in CM 1.2, since version 1.3 only the 3-parameters version is supported (the one with settings included). You can check the changesets and confirm this (see changeset cf9aca05fce2).

Nov 2, 2011 at 11:10 PM

I agree its an assembly version conflict.

I removed the v1.2 nuget package, cleaned project, downloaded an built latest v1.3 Caliburn, added reference and ... same error!


Nov 2, 2011 at 11:15 PM

Created new WPF project, added Caliburn reference and can see 3rd parameter.

Previous project was created using Caliburn WPF template. Must have added reference to v1.2 somewhere. Need to find where.

Nov 2, 2011 at 11:17 PM

Well, at least you pinned out the issue (more or less)! :)

Nov 2, 2011 at 11:21 PM

Found - Caliburn template puts assemblies in a Lib folder. Removed and all working now. Thanks for help BladeWise.

Nov 2, 2011 at 11:22 PM
Edited Nov 2, 2011 at 11:22 PM

No problem. Glad to be helpful!