HTTP协议中没有的WebRequest下单支持 [英] HTTP protocol not supported in WebRequest under mono

查看:308
本文介绍了HTTP协议中没有的WebRequest下单支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的MacBook的一个最奇怪的问题。我有一个在我的MacBook上运行单C#应用程序。该应用程序通过HTTP的Web服务进行通信,它完美的作品在我的旧的MacBook

I am having the weirdest issue on one of my Macbooks. I have a C# application that runs under mono on my Macbook. The application communicates with a web service through HTTP and it works perfectly on my old Macbook.

我买了一台新的MacBook和是在试探我的应用程序,但由于某种奇怪的原因:

I bought a new macbook and was testing my application but for some weird reason:

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



抛出引发NotSupportedException 与所提供的URI作为。异常消息

Throws NotSupportedException with the provided URI as the exception message.

我也试过以下内容:

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

和得到了同样的异常。我不知道为什么事情会疯了,想不出任何可能导致这一点,因为它似乎在其他Mac完美地工作。

and got the same exception. I'm not sure why things are going crazy and cannot think of anything that could cause this since it seems to work perfectly on other Macs.

编辑:

我使用Mono的版本是 2.10.11

The Mono version I'm using is 2.10.11

为异常堆栈跟踪为:

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

问候

推荐答案

该WebRequest.GetCreateor获取其从app.config中/ machine.config中,具体而言,配置部分 system.net/webRequestModules 支持的协议列表。

The WebRequest.GetCreateor gets its list of supported protocols from app.config/machine.config, specifically, the configuration section system.net/webRequestModules.

如果那里没有找到该协议(在你的情况下,HTTP),它抛出你的NotSupportedException异常。

If the protocol (in your case "http") isn't found there, it throws your NotSupportedException.

所以,请检查您的Machine.config,它可能丢失正确的webRequestModules。它应该有HTTP - > HttpRequestCreator

So, check your machine.config, it's probably missing the correct webRequestModules. It should have "http" -> HttpRequestCreator.

或者,尝试调用HttpWebRequest的私人构造函数通过反射,如果一切都失败了。

Or, try calling the private constructor of HttpWebRequest through reflection, if all else fails.

这篇关于HTTP协议中没有的WebRequest下单支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆