Gotcha: Don’t Call a Namespaces "Models" in Caliburn Micro

Here’s how Caliburn finds the view for your view model: it removes the word Model from the FullName of your view model.  So

  • Caliburn.Micro.Hello.ShellViewModel becomes Caliburn.Micro.Hello.ShellView
  • Caliburn.Micro.ViewModels.ShellView becomes Caliburn.Micro.Views.ShellView

However, it’s important to understand that it removes every instance of the word model from the FullName.  So

  • Caliburn.Micro.Models.ShellViewModel becomes Caliburn.Micro.s.ShellView

Since it’s highly unlikely you created a namespace called “s”, it follows that the convention is going to fail to find the view.

More generally, this is a classic case of under-reporting in errors.  The error tells you that it couldn’t find the view, but what it doesn’t tell you is where it looked.  This being an open source application, it’s relatively easy to find out once you’ve determined that you need to be looking at the ViewLocator code.  But still, the error could be better, and it would save people who had made a mistake some time.

Technorati Tags: ,

Published by

Julian Birch

Full time dad, does a bit of coding on the side.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s