System.Web.Http and Sytem.Net.Http

I started working on a .NET based project that uses Dependency Injection, Http Client classes etc. It originally makes Web API calls to a/some server(s). When i attempted to setup that project in my machine, i got a lot of build errors and all of them due to

  • Missing Types

A little more investigation revealed that the types that are not found are HttpResponseMessage, HttpClient, IDependencyResolver

I enabled verbose logging in MSBuild and further found out that the assemblies which are suppose to be present (System.Web.Http.dll and System.Net.Http.dll) are missing. But this application is running fine in production, other developer machines, QA and anything else that exists already. After studying all the deployment environments and the people working in the project already, i kind of figured out that there are two problems

  • IDependencyResolver (part of Sytsem.Web.Http assembly) is part of the .NET framework in the past (< .NET 4.5) and it is moved to the Nuget package Microsoft.AspNet.WebApi.Core. Choose the appropriate version.
  • All the missing Http* classes are part of the System.Net.Http assembly, which is available only in .NET Framework 4.5+.

To fix the issues, i have to retarget the projects and their transitive dependency chain to .NET 4.5 and also add the Nuget package to packages.config of each project.

The fact that it works for other developers, is because they have a folder called "missing assemblies" which is handed over as part of the onboarding process :P. I hope we don't need to do that any more !. Yet another, 'I Fix Therfore I Am' moment.

soundararajan