Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Annoying Build Error while Implementing the IControllerFactory Interface

DZone's Guide to

Annoying Build Error while Implementing the IControllerFactory Interface

·
Free Resource
Today I wanted 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.

Topics:

Published at DZone with permission of Gil Fink, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}