Derik Whittaker



Missing Method Exception w/ Caliburn.Micro when using INavigationService

As I continue to build out a WP7 application using Caliburn Micro I ran into a odd error.  When trying to inject the INavigationService I would get a ‘Missing Method’ exception as shown below:


When I first started to look at the error it did not make any sense.  Everything appeared to be in order, but of course there had to be something wrong.  lets take a look at what was wrong and how to resolve it.

When building out a WP7 app using Caliburn.Micro when you let the Visual Studio template the template will create a ‘framework’ folder for you.  This framework folder has some killer code in it, but be careful because much of what is generated here also lives in the Caliburn.Micro namespace (in fact all this code may be duplicated, but I am too new to the framework to know for 100%).

The first thing I did when setting up my application is to add the following method to my PhoneContainer.cs class (this is based on a few example projects I have seen)

public void RegisterPhoneServices( bool treatViewAsLoaded = false )
    RegisterInstance( typeof( Caliburn.Micro.INavigationService ), null, new FrameAdapter( _bootstrapper.RootFrame, treatViewAsLoaded ) );
    RegisterInstance( typeof( Caliburn.Micro.IPhoneService ), null, new PhoneApplicationServiceAdapter( _bootstrapper.PhoneService ) );
    RegisterSingleton( typeof( IWindowManager ), null, typeof( WindowManager ) );
    RegisterSingleton( typeof( IEventAggregator ), null, typeof( EventAggregator ) );

The intent of the code above is to setup the IoC container with many of the default services I want to use from the framework.  You will notice that in the first two I have prefixed the interfaces with Caliburn.Micro (which we my undoing as I will learn).  The reason for this is that my project spans multiple dll’s and this was how I could get it to compile.

When I would try to run this code:

var instance1 = container.GetInstance( typeof( DashboardViewModel ), "DashboardViewModel" );

This when I would get the missing method exception from above.  After about 10 minutes of looking at this code and trying a few different things I knew for a FACT that the error was due to the usage of the INavigationService interface, now just to understand what the root cause was.

As I went back to the location where I register the interface it downed on me.  What is the namespace of the ‘FrameAdapter’ object?  Of course it was NOT Caliburn.Micro…hum could this be the cause.  Turns out it was.  When I prefixed FrameAdapter to look like below

RegisterInstance( typeof( Caliburn.Micro.INavigationService ), null, new Caliburn.Micro.FrameAdapter( _bootstrapper.RootFrame, treatViewAsLoaded ) );

Everything now worked as expected.  The moral of the story is this.  If you are going to use this awesomeness which is Caliburn.Micro either use the libraries from the Caliburn.Micro.dll or DON’T.  Do NOT mix apples and oranges.

Till next time,

P.S. I am sure I am really doing something wrong in general w/ Caliburn.Micro but hey that is how you learn right Smile

Posted 05-09-2011 7:40 AM by Derik Whittaker
Filed under: , ,



Rob Eisenberg wrote re: Missing Method Exception w/ Caliburn.Micro when using INavigationService
on 05-09-2011 9:02 AM

Good post. Sorry for the confusion. I'm actively working to improve some of this stuff for the next version. If you look in the trunk, you will see that I now have a Caliburn.Micro.Extensions dll which houses the simple container, new functionality for tombstoning and the new functionality for launcher/choosers. The phone container there has a method which automatically configures all the services. So, in the next release, this should all be mostly avoided.

Derik Whittaker wrote re: Missing Method Exception w/ Caliburn.Micro when using INavigationService
on 05-09-2011 9:13 AM


Sweet, but no big deal man.  Just thought I would post in case anyone else made the same bone head mistake I did.

Keep up the great work

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)