Make sure that the controller has a parameterless public constructor in Unity

后端 未结 2 1476
梦如初夏
梦如初夏 2021-01-12 06:27

I got this problem with the Controller:
An error occurred when trying to create a controller of type \'*.WebMvc.Controllers.HomeController\'. Make sure that t

2条回答
  •  清歌不尽
    2021-01-12 07:00

    This can also be due to an exception in the parameter-injected constructor of the outer type that is being resolved. The dependencies of that type's constructor might be getting resolved successfully, but if there is an exception in the outer constructor, Unity will report it as "Type Test.Controllers.MyControllerWithInjectedDependencies does not have a default constructor".

提交回复
热议问题