Annoying Build Error while Implementing the IControllerFactory Interface

May 20, 2010

Annoying Build Error while Implementing the IControllerFactory Interface

Today I wanted Annoying Build Error while Implementing the IControllerFactory Interface
to check
something 
in the MVC
framework
in
regard to the  
implementing the
IControllerFactory interface. I couldn’t guessed that it will take me
ten minutes to figure out an annoying build error which I will
explain here how to resolve it.

The Scenario

You want to implement the IControllerFactory interface but not in
the MVC framework generated web application. The implementation
would exists in another class library. I set a reference for the
System.Web.Mvc dll and also to the System.Web dll (which holds the
System.Web.Routing.RequestContext which is needed for the
CreateController method.

The Problem

I finished to implement the interface and compiled the solution.
A very strange “does not implement interface member
‘System.Web.Mvc.IControllerFactory.CreateController(
System.Web.Routing.RequestContext, string)
” error message is
jumping at me from the Error List View. Since I know that I
finished to implement all the methods in the interface this error is
very interesting and annoying.
I searched the web for indications about this error and found
some references without any solution such as this post.

The solution

I tried to figure out what was missing. So I guessed that I wasn’t
referencing another assembly which causes the inappropriate error.
My first guess was the System.Web.Routing dll. I referenced it
and the build succeeded without any errors.

Summary

Sometimes more informative errors can help you to find the
problems you face. In this case the error wasn’t helpful and
lead me to think that something in my implementation was
wrong. I hope that this post will help you if you get stuck
with this error.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>