The type String cannot be constructed

后端 未结 5 1428
梦如初夏
梦如初夏 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:00

    Registering the HttpConfiguration object as an instance in UnityContainer will also help resolve the issue.
    Just need to add to add the below line while registering in UnityContainer.

    public static void RegisterTypes(IUnityContainer container) {
        container.RegisterInstance(GlobalConfiguration.Configuration);
    }
    

    This will help Unity resolve the config parameter, when it invokes the constructor with the parameter.

    public HelpController(HttpConfiguration config) {
        Configuration = config;
    }
    

提交回复
热议问题