【发布时间】:2013-11-23 21:25:53
【问题描述】:
我想在我的 Ubuntu 服务器上执行我在 Windows 中编译的 C# 应用程序。
我正在使用 .Net Framework 4.5 版(由于某些 3rd 方 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 和 .NET 不是 100% 兼容的。如果您为 .NET 构建程序,它不一定会在 Mono 上运行。
-
是的,但是 mono 文档说 System.Net 应该完全实现。如果没有,是否有任何解决方法?
-
它在哪里说的?
-
go-mono.com/status/… 第一个位置。如果我错过了,那是没有解决方法吗?
-
您必须使用 Mono 3.2.*,因为只有该版本具有 .NET 4.5 配置文件。 Mono 2.* 已过时。
标签: c# mono system.net missingmethod