Fix To: 'Attempt by method System.Web.Http.GlobalConfiguration..cctor()' to access field Error

"Attempt by method 'System.Web.Http.GlobalConfiguration..cctor()' to access field 'System.Web.Http.GlobalConfiguration.CS$<>9__CachedAnonymousMethodDelegate2' failed."

Today when I was working on WebAPi and enabling CORS for WebAPI, I confronted an error which took time to resolve and finally resolved. To mitigate such issues you shouldinstall one of the possible insatalltions using NuGet Package Manager console.

Go to NuGet Package Manager console and select Default Project in which you would like to get this feature enabled and run the following command as shown below.

Install-Package Microsoft.AspNet.WebApi –IncludePrerelease

It will resolve an error and will help you to proceed further with your business logic.