我想在我的Ubuntu服務器上執行我在Windows下編譯的C#應用程序。缺失方法異常單聲道
我使用.Net Framework版本4.5(不能更改它的某些第三方API的原因)。
我已經爲Ubuntu安裝了最實際的Mono版本(2.10.8)。我的應用程序在Windows操作系統上使用VisualStudio 2012進行編譯(7)。
我正在嘗試向其他網站發送一些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;
,我來自單收到錯誤來這裏:
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
我GOOGLE了2天,現在可以」找到一個解決方案。 :(
更新:
屬性set_Date和set_host目前沒有實現單(我升級我的版本到3.x)
單聲道和.NET之間不是100%兼容如果你構建.NET程序,也不一定會在Mono運行 –
是的,但單聲道文件說System.Net應該是完整實施。如果沒有,是否有任何解決方法? – Iwan1993
它在哪裏說的? –