The type String cannot be constructed

后端 未结 5 1455
梦如初夏
梦如初夏 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 17:10

    The reason this happens is because Unity will by default choose to use the constructor with the most parameters thus bypassing the default constructor.

    Comment out the two constructors that exist in the HelpController template and add a default one that sets the configuration.

        //public HelpController()
        //    : this(GlobalConfiguration.Configuration)
        //{
        //}
    
        //public HelpController(HttpConfiguration config)
        //{
        //    Configuration = config;
        //}
    
        public HelpController()
        {
            Configuration = GlobalConfiguration.Configuration;
        }
    

提交回复
热议问题