单声道下的WebRequest不支持HTTP协议

我在我的一台Macbook上遇到了最棘手的问题。 我有一个C#应用程序在我的Macbook上运行单声道。 该应用程序通过HTTP与Web服务进行通信,它在我的旧Macbook上完美运行。

我买了一个新的macbook并正在测试我的应用程序,但出于一些奇怪的原因:

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(sURI); 

使用提供的URI作为exception消息抛出NotSupportedException

我也尝试了以下内容:

  HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://www.google.com"); 

并得到了同样的例外。 我不确定为什么事情会变得疯狂,并且无法想到任何可能导致这种情况的事情,因为它似乎在其他Mac上完美运行。

编辑:

我正在使用的Mono版本是2.10.11

exception的堆栈跟踪是:

 Webrequest.Create Exception string : System.NotSupportedException: http://www.google.com/ at System.Net.WebRequest.GetCreator (System.String prefix) [0x00000] in :0 at System.Net.WebRequest.Create (System.Uri requestUri) [0x00000] in :0 at System.Net.WebRequest.Create (System.String requestUriString) [0x00000] in :0 at MyApp.XSPManager.GeneralSOAPFunction (System.String serverName, System.String settingsAsXml, SharedLib.zErrorCodes& errorCode, System.String& message, System.String& actionType) [0x00000] in :0 

问候

WebRequest.GetCreateor从app.config / machine.config获取支持的协议列表,特别是配置部分system.net/webRequestModules

如果在那里找不到协议(在你的情况下为“http”),它会抛出你的NotSupportedException。

所以,检查你的machine.config,它可能缺少正确的webRequestModules。 它应该有“http” – > HttpRequestCreator。

或者,如果所有其他方法都失败,请尝试通过reflection调用HttpWebRequest的私有构造函数。