inversion of control - Setting ASP.NET MVC ControllerFactory has no effect -
i'm trying have asp.net mvc2 controllers built using structuremap asp.net doesn't seem remember i've called controllerbuilder.current.setcontrollerfactory
in global.asax file.
specifically error controller has no parameterless constructor. stack trace reveals custom controllerfactory
never executed.
here call method should tell asp.net controllerfactory use:
sub application_start() registerroutes(routetable.routes) controllerbuilder.current.setcontrollerfactory(gettype(structuremapcontrollerfactory)) bootstrapper.registerdependencies() end sub
and here's exception receive.
[targetinvocationexception: exception has been thrown target of invocation.] system.runtimetypehandle.createinstance(runtimetype type, boolean publiconly, boolean nocheck, boolean& canbecached, runtimemethodhandle& ctor, boolean& bneedsecuritycheck) +0 system.runtimetype.createinstanceslow(boolean publiconly, boolean fillcache) +86 system.runtimetype.createinstanceimpl(boolean publiconly, boolean skipvisibilitychecks, boolean fillcache) +230 system.activator.createinstance(type type, boolean nonpublic) +67 system.web.mvc.defaultcontrollerfactory.getcontrollerinstance(requestcontext requestcontext, type controllertype) +80
why asp.net forgetting controllerfactory use?
how structuremapcontrollerfactory defined? have default constructor?
if not, try using second overload of setcontrollerfactory method:
// first create controllerfactory instance... controllerbuilder.current.setcontrollerfactory(controllerfactory);
Comments
Post a Comment