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.
I bought a new macbook and was testing my application but for some weird reason:
HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create(sURI);
Throws NotSupportedException
with the provided URI as the exception message.
I also tried the following:
HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://www.google.com");
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.
Edit:
The Mono version I'm using is 2.10.11
The stack trace for the exception is:
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
Regards
The WebRequest.GetCreateor gets its list of supported protocols from app.config/machine.config, specifically, the configuration section
system.net/webRequestModules
.If the protocol (in your case "http") isn't found there, it throws your NotSupportedException.
So, check your machine.config, it's probably missing the correct webRequestModules. It should have "http" -> HttpRequestCreator.
Or, try calling the private constructor of HttpWebRequest through reflection, if all else fails.