3

I updated to the final version of MVC4 and now my tests are failing with this error:

System.MissingMethodException : Method not found: 'Void System.Net.Http.ObjectContent`1..ctor(!0, System.Net.Http.Formatting.MediaTypeFormatter, System.Net.Http.Headers.MediaTypeHeaderValue)'. 
at System.Net.Http.HttpRequestMessageExtensions.CreateResponse(HttpRequestMessage request, HttpStatusCode statusCode, T value, HttpConfiguration configuration)

On my unit test I have (it was working with RC version):

var configuration = new HttpConfiguration(); 
var request = new HttpRequestMessage(); 
var controller = ClassUnderTest; 
controller.Request = request; 
controller.Request.Properties["MS_HttpConfiguration"] = configuration;

When I run my test I have the exception on this line of code inside the controller:

return Request.CreateResponse(HttpStatusCode.Created, myObj);

I tried different things but I could not fix the tests. Any ideas?

1 Answer 1

3

I solved the problem and it was quite simple.

I unistalled the NuGet packages relative to the RC version and installed the the new one. This solve the problem

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.