Monday 25 October 2010

A common XNA error


One of the XNA errors that regularly manages to confuse me is the exception:
Service provider object of type <Insert your object here> must be assignable to service type System.RuntimeType.
Since a quick Google search for the exception provided few results I figured I post the cause and solution.
In XNA there is the game.ServiceProvider object that provides a neat service based way of storing you game services without tying them directly to business logic. The predominant way of calling this method is:

this.Services.AddService(typeof(<Iinterface>), <Object>);
 

The exception occurs when your <Object> does not implement the provided <Iinterface> interface. Really simple and trivial to fix. Unfortunately forgetting to implement a particular interface seems to be something I regularly when I am developing a piece of functionality in small chunks of time. Just unfortunate that the error message is so unspecific.
Hope this helps
-Leon

Tuesday 19 October 2010

No Silver Bullet

I’ve been going through my old email and it seems that I am postponing setting up this blog since January 2007 as that’s the date Dr. Brooks gave me his blessing for the name of the site. I also think that I would probably have postponed it for quite a while to come if it hadn’t been for my foray into SP2010 and XNA for Windows Phone.

There are just to many things in there that need to be written down. Even if only to help me find them again myself.

Given the title of the site I would like to end this first post with a fitting reference. Software engineers will recognize the title of this website as a reference to Fred Brooks's 1986 paper, "No Silver Bullet", now reprinted as Chapter 16 in his The Mythical Man-Month, Anniversary Edition (1995).  Although my ideas are influenced by his writings, this website has no connection with Dr. Brooks. (although I did asked and received his  approval to name the site the way I did)
-Leon