簡體   English   中英

缺少方法異常單聲道

[英]Missing Method exception mono

我想在我的Ubuntu服務器上執行我在Windows上編譯的C#應用​​程序。

我正在使用.Net Framework 4.5版(不能改變它的一些第三方api的原因)。

我安裝了Ubuntu最實用的Mono版本(2.10.8)。 我的應用程序是在Windows操作系統(7)上使用VisualStudio 2012編譯的。

我正在嘗試向其他網站發布一些Post請求並解析數據。 這是創建請求的代碼(完美地適用於Windows):

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri.AbsoluteUri);

req.UserAgent = this.UserAgent;
req.CookieContainer = this.Cookies;
req.Referer = this.Location;
req.Host = uri.Host;
req.AllowAutoRedirect = false;

我從Mono得到的錯誤來到這里:

Unhandled Exception: System.MissingMethodException: Method not found: 'System.Net.HttpWebRequest.set_Date'.
  at manager.http.HttpBrowser.GetPostWebRequest (System.String url, System.Collections.Generic.Dictionary`2 postdata, System.Collections.Generic.Dictionary`2 headers) [0x00000] in <filename unknown>:0
  at manager.http.HttpBrowser.Post (System.String url, System.Collections.Generic.Dictionary`2 postdata, System.Collections.Generic.Dictionary`2 headers) [0x00000] in <filename unknown>:0
  at manager.http.HttpBrowser.Post (System.String url, System.Collections.Generic.Dictionary`2 postdata) [0x00000] in <filename unknown>:0
  at manager.networks.components.MyClass.MyMethod() [0x00000] in <filename unknown>:0
  at manager.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: 'System.Net.HttpWebRequest.set_Date'.
  at manager.http.HttpBrowser.GetPostWebRequest (System.String url, System.Collections.Generic.Dictionary`2 postdata, System.Collections.Generic.Dictionary`2 headers) [0x00000] in <filename unknown>:0
  at manager.http.HttpBrowser.Post (System.String url, System.Collections.Generic.Dictionary`2 postdata, System.Collections.Generic.Dictionary`2 headers) [0x00000] in <filename unknown>:0
  at manager.http.HttpBrowser.Post (System.String url, System.Collections.Generic.Dictionary`2 postdata) [0x00000] in <filename unknown>:0
  at manager.networks.components.MyClass.MyMethod() [0x00000] in <filename unknown>:0
  at manager.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

我用谷歌搜索了2天,找不到解決方案。 :(

更新:

屬性set_Date和set_host當前未在Mono中實現。 (我將我的版本升級到3.x)

Mono 2.x不支持.NET 4.5,升級到Mono 3.x.

你有一個指南: 在Ubuntu / Debian中安裝Mono 3.x.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM