The type String cannot be constructed

后端 未结 5 1446
梦如初夏
梦如初夏 2021-02-18 16:29

I\'m using Web.api and Unity and I am getting the following error when trying to open the default \"help\" area:

[InvalidOperationException: The type String cann         


        
5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-18 16:59

    I think a better way is to add InjectionConstructor attribute to the default constructor. This attribute forces unity to use the decorated constructor.

    Example:

    public class HelpController : Controller
    {
        private const string ErrorViewName = "Error";
    
        [InjectionConstructor]
        public HelpController()
            : this(GlobalConfiguration.Configuration)
        {
        }
    

提交回复
热议问题