Pascal
Pascal

Reputation: 12855

HttpSelfHostConfiguration can not be resolved although system.web.http is referenced

Although I have added the System.Web.Http assembly to my project X the HttpSelfHostConfiguration type can not be resolved. And I use resharper...

The odd thing is that the HttpConfiguration works.

When I run some integration tests from project Y using static classes in project X I get a runtime exception: The file or assembly System.Web.Http, Version=5.0.0.0 can not be found etc...

Why can I not resolve the HttpSelfHostConfiguration?

Upvotes: 3

Views: 5273

Answers (2)

Habeeb
Habeeb

Reputation: 8007

Solution: You can add reference from the NuGet Package Library. Search for Package: Microsoft.AspNet.WebApi.SelfHost and install it.

enter image description here

For those who has any confusion in adding NuGet Package Reference: In Visual Studio Solution Explorer, Right Click References > Manage NuGet Packages enter image description here

Upvotes: 1

Markus
Markus

Reputation: 22456

HttpSelfHostConfiguration is located in the assembly System.Web.Http.SelfHost.dll and the namespace System.Web.Http.SelfHost. So you might need to add a reference to this assembly, maybe by adding the Self Host Nuget package.

If you've already added this package, the error might be related to the other errors you're experiencing regarding System.Web.Http v5.0.0.0: I've also experienced some strange behavior after upgrading a Web API project to VS2013. I could only solve this by removing the Web API Nuget packages (the error message resembled yours), deleting some remainders of old versions in the packages folder and adding the required Nuget packages anew.

Upvotes: 4

Related Questions