1
嗨,我裝箱與團結DLL一個網頁API,當我整合這首先我必須面對與團結Asp.net網頁API String類型不能構建
無法加載文件或程序集「系統.Web.Http,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依賴項之一。定位的程序集清單定義與程序集引用不匹配。 (異常來自HRESULT:0x80131040)
的錯誤,我已經通過添加解決它:
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
在Web配置文件之後,我運行應用程序並 我得到了如下錯誤
無法構造String類型。您必須配置容器以提供此值。
然後我在網上搜索和我說:
[InjectionConstructor]
的構造,它不列入解決問題 我使用ApiController
我的控制器代碼如下
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
}
}
任何人請提前幫助我。