Ensure that HttpConfiguration.EnsureInitialized()

前端 未结 14 1011
一生所求
一生所求 2020-11-30 23:31

I\'ve installed Visual Studio 2013 and when I run my app I get the error below.

I\'ve got no idea as to where I\'m to initialized this object.

What to do?

相关标签:
14条回答
  • 2020-12-01 00:02

    I began getting this error one day. After I'd altered our app to call EnsureInitialized() I was able to see the root cause.

    I had a custom attribute, a filter, on an action. That attribute class had had a breaking change made in the NuGet package in which it lives.

    Even though I'd updated the the code and it all compiled, the local IIS worker was loading an old DLL and not finding a class member during initialization, reading attributes on actions etc.

    For some reason (possibly due to order/when our logging is initialized), this error was not discoverable, possibly leaving the WebAPI in a strange state, until I'd added EnsureInitialized() which caught the exception and surfaced it.

    Performing a proper bin and obj clean via a handy script resolved it.

    0 讨论(0)
  • 2020-12-01 00:02

    In my case , i used an Entity as parameter of my action that its 'Schema' is missing.

    Wrong attribute:

    [Table("Table name", Schema = "")]
    

    Correct :

    [Table("Table name", Schema = "schema name")]
    
    0 讨论(0)
提交回复
热议问题