(HRESULT异常:0x80131040)

时间:2014-05-05 09:10:38

标签: c# asp.net-mvc-4 asp.net-web-api-routing

我正在使用Rest实现WepApi服务,但是我无法浏览它显示无法加载文件或程序集的网址' MySql.Data.Entity.EF5,Version = 6.9.0.0,Culture =中性,PublicKeyToken = c5687fc88969c44d'或其中一个依赖项。定位的程序集的清单定义与程序集引用不匹配。

IRank.cs enter code here

 interface Icalculation
{
    collection_master AgentRank(int id);
}

Rank.cs

enter code here


   public collection_master AgentRank(int id)
    {


        EntityConnection con = new EntityConnection("name=calculationEntities");
        **con.Open();**
        EntityCommand cmd = new EntityCommand();
        cmd.CommandText = "SELECT Agentid,year(Date_Time) as Year,monthname(Date_Time) as Month,SUM(AmountRecevied) as Amount,@rownum := @rownum + 1 AS Rank FROM collection_master join outstanding_master on collection_master.CustomerID =outstanding_master.CustomerID  and  outstanding_master.PhoneNumber='id',(SELECT @rownum := 0) r GROUP BY AgentID,year(Date_Time),monthname(Date_Time) ORDER BY Amount DESC";



        DbDataReader rdr = cmd.ExecuteReader(CommandBehavior.SequentialAccess);
        collection_master list = new collection_master();
        while (rdr.Read())
        {
            collection_master coll = new collection_master();
            coll.CustomerID = Convert.ToInt32(rdr["CustomerID"]);
            coll.AmountRecevied = Convert.ToInt32(rdr["AmountRecevied"]);
            coll.Date_Time = Convert.ToDateTime(rdr["Date_Time"]);
            coll.Area = rdr["Area"].ToString();
            coll.AgentID = Convert.ToInt32(rdr["AgentID"]);
            coll.Money_Receipt_No = Convert.ToInt32(rdr["Money_Receipt_No"]);
            coll.Payment_Mode = rdr["Payment_Mode"].ToString();
            coll.Money_Receipt_Photo = (byte[])rdr["Money_Receipt_Photo"];


        }
        return list;


    }



enter code here

RankController

 public class RankController : BaseApiController
{
    static readonly Icalculation obj = new calculation();
    public RankController()
        : base()
    { }

    [System.Web.Http.AcceptVerbs("GET", "HEAD")]
    [System.Web.Http.HttpGet]

    public RankModels  GetRanks(int number)
    {
        collection_master col =  obj.AgentRank(number);

        if (col == null)
            throw new HttpResponseException(HttpStatusCode.NotFound);
        return TheModelFactory.created(col);

    }
}

ApiRouter

    public static void Register(HttpConfiguration config)
    {
        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

        config.Routes.MapHttpRoute(
            name: "Insertapi",
            routeTemplate: "api/{controller}/{action}/{id}",
              defaults: new { controller = "Insert" }


        );


        config.Routes.MapHttpRoute(
           name: "Rankapi",
           routeTemplate: "api/{controller}/{action}/{id}",
             defaults: new { controller = "Rank" }


       );




        var xml = GlobalConfiguration.Configuration.Formatters.XmlFormatter;
        xml.UseXmlSerializer = true;

    }

0 个答案:

没有答案