本文介绍了无法加载文件或程序集'System.Net.Http.Formatting,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。该系统找不到指定的文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我在一个mvc 4项目上工作,我想打电话给mvc webapi

我运行时遇到上述错误。

下面的代码来自我的mvc 4网页项目



 私人折扣GetMultibuyDiscount(MultibuyBag包)
{
string uri = System.Configuration.ConfigurationManager.AppSettings [ 下一个:使用:MultibuyServiceURI];
var client = new HttpClient();

var response = client.PostAsJsonAsync(uri + Post?timeout = 2000,bag).Result; // 92 // 5683 .PostAsJsonAsync
if (response.IsSuccessStatusCode)
{
return response.Content.ReadAsAsync< Discount>()。Result;
}

Console.WriteLine( {0}({1}) ,( int )response.StatusCode,response.ReasonPhrase);
return new Discount();

}





当它准备好client.PostAsJsonAsync时它会突破上述错误。

我做错了什么

非常感谢你的帮助

解决方案

hello
i am wroking on a mvc 4 project where i wanted to call a mvc webapi
i get the above error when i run it.
the code bellow is from my mvc 4 web project

private Discount GetMultibuyDiscount(MultibuyBag bag)
        {
            string uri = System.Configuration.ConfigurationManager.AppSettings["Next:Use:MultibuyServiceURI"];
            var client = new HttpClient();

            var response = client.PostAsJsonAsync(uri + "Post?timeout=2000", bag).Result; //92 //5683 .PostAsJsonAsync
            if (response.IsSuccessStatusCode)
            {
                return response.Content.ReadAsAsync<Discount>().Result;
            }

            Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            return new Discount();

        }



when it ready client.PostAsJsonAsync it break with the above error.
what i have done wrong
appreciate all your help

解决方案


这篇关于无法加载文件或程序集'System.Net.Http.Formatting,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。该系统找不到指定的文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 00:36