Hi I am crating a web api with unity dll and when i am integrating this first i have faced
Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
error i have resolved it by adding:
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
in the web config file and after that i run the application and i got the error as below
The type String cannot be constructed. You must configure the container to supply this value.
Then i searched the internet and i have added:
[InjectionConstructor]
to the constructor and it doesnot resolves the issue
I am using ApiController my controller code is as below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Configuration;
using Microsoft.Practices.Unity;
namespace Check.Api.Controllers
{
public class CommonController : ApiController
{
#region Variables
/// <summary>
/// Business layer of .
/// </summary>
private IBLPIP _blPIP;
private IBLCommon _blCommon;
#endregion
#region Constructor
/// <summary>
/// Constructor of Login API Controller
/// </summary>
/// <param name="auth"></param>
[InjectionConstructor]
public CommonController( IBLCommon blCommon)
{
this._blCommon = blCommon;
}
#endregion
#region Methods
[HttpGet]
public HttpResponseMessage Get_CountryList()
{
try
{
List<Country> CountryList = _blCommon.GetCountryList();
return Request.CreateResponse<List<Country>>(HttpStatusCode.OK, CountryList);
}
catch (Exception ex)
{
LogUtil.Error("LoginServiceController\\Login\n" + ex.Message);
return Request.CreateResponse(HttpStatusCode.NotFound);
}
}
#endregion
}
}
Any one please help me thanks in advance.