"Does not implement IControllerFactory.CreateController" in Visual Studio 2010
When compiling this code:
public class WindsorControllerFactory : IControllerFactory
{
private readonly WindsorContainer _container;
public WindsorControllerFactory(WindsorContainer container)
{
_container = container;
}
public IController Crea开发者_JS百科teController(RequestContext requestContext,
string controllerName)
{
return (IController)_container.Resolve(controllerName);
}
public void ReleaseController(IController controller)
{
_container.Release(controller);
}
}
I am getting this error:
'WindsorControllerFactory' does not implement interface member 'System.Web.Mvc.IControllerFactory.CreateController(System.Web.Routing.RequestContext, string)'
Well, it obviously implements this member. Has anyone encountered this problem?
I reproduced this on the RTM, opened a ticket with Microsoft.
Error went away after I added reference to System.Web.Routing 4.0.0.0. Before this it was indirectly referenced to 3.5.0.0 version (through System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
Thus i have the following references:
System.Web.Mvc 2.0.0.0 (v2.0.50727)
System.Web.Routing 4.0.0.0 (v4.0.30128)
you might have two conflicting versions of System.Web.routing or something like that.
There is also a RequestContext
class in the System.ServiceModel.Channels
namespace; included in the System.ServiceModel.dll assembly.
Hover over the RequestContext argument type of your your method and check that it pointing to the correct one.
More information here
Include a reference to System.Web (v4.0.30319).
精彩评论