This project is read-only.

Method not found exception after updating MVC via nuget

Sep 12, 2012 at 3:23 PM

I am using Visual Studio 2012 (RTM) to create an MVC 4 project that uses Web API endpoints, and I am trying to get the OData querying to work.

I just tried to install the latest nightly build of the OData nuget package, and now when I run my application, I get this error:

Method not found: 'System.Web.Http.Services.DefaultServices System.Web.Http.HttpConfiguration.get_Services()'.

It occurs when I try to add a custom action filter:

GlobalConfiguration.Configuration.Filters.Add(new ValidationActionFilter());

and this is the ValidationActionFilter code: 

    public class ValidationActionFilter : System.Web.Http.Filters.ActionFilterAttribute
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
            var modelState = actionExecutedContext.ActionContext.ModelState;
            if (!modelState.IsValid)
                var errors = new Dictionary<string, string>();
                foreach (var key in modelState.Keys)
                    var state = modelState[key];
                    if (state.Errors.Any())
                        errors.Add(key, state.Errors.First().ErrorMessage);

                var res = new HttpResponseMessage(HttpStatusCode.BadRequest);
                res.Content = new StringContent(new JavaScriptSerializer().Serialize(errors));
                res.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                actionExecutedContext.Response = res;

From what I found Googling that exception with Bing, the error means that I have an older version of the MVC 4 binaries in my GAC. 

I'm not gacutil wizard, but I couldn't find any references to any older version of MVC 4.

The project was working before I updated and the only thing that has changed is installing the latest nuget package.

The version that was working was: X.0.20505
The version that is not working is: X.0.20710

Sep 13, 2012 at 3:50 PM

I had this same problem. Other posts say to make sure that ALL of your nuget packages are updated in every relevant project. Having done that, I was still experiencing the problem.

I was able to resolve the issue by wiping out all of the contents of the bin folders (basically like a forced "Clean"). This ensures that the DLL files all get updated with the new packages code.

Sep 13, 2012 at 4:40 PM

Well, I found the DLL that is the problem child.  It's the System.Net.Http.Formatting dll.  No matter how many times I clear and re-build, I keep getting the dll and not the

A temporary solution has been to create a new project and update everything to the latest and manually copy the dll over.  I love NuGet, but some times it makes things a wee bit difficult.

A way to repro the problem is this:

  1. Create a brand new MVC 4 app (Web API type)
  2. Update to all the latest MVC and Web API NuGets
  3. Manually remove the System.Net.Http.Formatting dll
  4. Re-add the System.Net.Http.Formatting dll

I don't know how to recover from that other than by manually copying the dll over.

Any help here would be awesome

Sep 14, 2012 at 11:27 AM

The OData preview works against the RTM versions of the ASP.NET Web API (which is version X.0.20710), Updating the ASP.NET Web API assemblies is probably what is causing the problems. Try instead using the RTM versions and *only* update the OData package to the latest nightly build and see if that works.



Mar 12, 2015 at 10:12 AM
This worked for me by cleaning my solution and running Package-Update.