亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

發布 ASP.NET MVC 應用程序時找不到擴展方法

發布 ASP.NET MVC 應用程序時找不到擴展方法

C#
翻過高山走不出你 2022-12-24 14:40:48
在 ASP.NET MVC 應用程序 (.NET 4.7) 中,我在HttpResponseMessage. 此方法是在 .NET Standard 2.0 項目中創建的。在調試和使用 IIS Express 時,它工作得很好。但是當發布到服務器時,它返回“找不到方法”錯誤。在服務器 (Windows Server 2008) 上安裝了所有需要的框架。當我在調用擴展方法的方法中使用 try/catch 時,錯誤變得很清楚。在開發過程中,我希望它能在服務器上運行。我是否缺少任何其他 .NET 框架?或者還有其他人作為可能的解決方案嗎?HttpResponseMessage response = client.GetAsync(UserManAPI).Result;if (response.IsSuccessStatusCode){    apiResponse = response.Content.ReadAsStringAsync().Result;}else    response.ThrowReynaersException();public static void ThrowReynaersException(this HttpResponseMessage response){        if (response.StatusCode == HttpStatusCode.OK)        {            using (var dataStream =                     response.Content.ReadAsStreamAsync().Result)            {                 if (dataStream != null)                 {                      var jsonResponse = JsonValue.Load(dataStream);                      if (jsonResponse != null)                      {                           var rex =                JsonConvert.DeserializeObject<ReynaersException(jsonResponse,                            new ReynaersExceptionConverter());                           if (rex != null) throw rex;                           var ex = JsonConvert.DeserializeObject<Exception>(jsonResponse, new ExceptionConverter());                           if (ex != null) throw ex.ToReynaersException();                            throw new                         ReynaersException(ErrorResourcesKeys.DefaultMessage);                    }                }            }        }    }提前致謝!
查看完整描述

1 回答

?
神不在的星期二

TA貢獻1963條經驗 獲得超6個贊

在 web.config 中嘗試此操作或使用 Nuget 包重新安裝“System.Net.Http”


<configuration>

    <system.web>

         <compilation>

             <assemblies>

                <add assembly="System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

             </assemblies>

          </compilation>

    </system.web>

</configuration>


查看完整回答
反對 回復 2022-12-24
  • 1 回答
  • 0 關注
  • 127 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號