System.IndexOutOfRangeException in MessageBinder.DetermineParameters

Dec 12, 2010 at 6:12 AM
Edited Dec 12, 2010 at 6:15 AM

While porting some existing screens to CM, I discovered that I get a System.IndexOutOfRangeException in MessageBinder.DetermineParameters when creating a close button on a view model inheriting from Screen. I have verified that this behavior exists in Change Set a8639bc9322d.

In order to replicate this behavior, create a WPF CM project from the template. Use the following for the view model:


using System.ComponentModel.Composition;
using CaliburnMicroCloseButtonExample.Framework;

namespace CaliburnMicroCloseButtonExample
    public class ShellViewModel : Screen, IShell
        public void Close() { }


Use this for the view:

<Grid x:Class="CaliburnMicroCloseButtonExample.ShellView"
    <Button x:Name="Close">Close</Button>


Dec 12, 2010 at 8:22 AM
Edited Dec 12, 2010 at 8:34 AM

Thanks for pointing it out.

It's an unfortunate side effect of conventions: since you created a "Close" action, CM attempts to find a "CanClose" guard function.
A function with this name does actually exists on Screen, though its signature is not intended to be used as a guard.
I guess this could be solved executing some more congruence check when attempting to find a viable guard (during execution context construction).

I added a ticket for this:

You can choose, however, a slightly different name or use the default TryClose method (if your method is intended to just close the screen).

Dec 16, 2010 at 12:03 AM

The issue is fixed as of changeset a6b5a421d26c