Main Site Documentation

CLR_E_NOT SUPPORTED Error on HttpWebRequest


#1

I am having some trouble with a HttpWebRequest. I am using a Cobra and the code to initialise Ethernet and send the data to server is detailed below:


	Ethernet.Enable();
	netInterfaces = NetworkInterface.GetAllNetworkInterfaces();

	// Wait for a Ethernet Cable to be connected
	while (!Ethernet.IsCableConnected) {
	  Debug.Print("Ethernet cable is not connected! Waiting ...");

	  // Wait a bit
	  Thread.Sleep(1000);
	}

	// Enable DHCP
	Debug.Print("Ethernet cable is connected!");
	Debug.Print("Enabling DHCP ...");

	if (netInterfaces[0].IsDhcpEnabled) { netInterfaces[0].RenewDhcpLease(); }
	else { netInterfaces[0].EnableDhcp(); }

	Debug.Print("Network settings:");
	Debug.Print("IP Address: " + netInterfaces[0].IPAddress);
	Debug.Print("Subnet Mask: " + netInterfaces[0].SubnetMask);
	Debug.Print("Default Getway: " + netInterfaces[0].GatewayAddress);
	if (netInterfaces[0].DnsAddresses.Length > 0) {
  	  Debug.Print("DNS Server:" + netInterfaces[0].DnsAddresses[0]);
	}
	else	{
	  Debug.Print("No DNS Server found");
	}


	webServerUri = WMStart.AppConfig.WMServerUri + @ "SiteComms/ProbeReading.aspx?                                        SiteData=" + "SiteName=" + siteName + ";" + "ProbeType=" + probeType.ToString() + ";" +											 "ProbeReading=" + probeReading.ToString();



	// Send the request to the server
	webRequest = (HttpWebRequest)WebRequest.Create(webServerUri);
	webRequest.Timeout	  = 60 * 1000;
	webRequest.Method 	  = "GET";
	webRequest.KeepAlive = false;

	webResponse = (HttpWebResponse)webRequest.GetResponse();

The output is as follows:

Initialising the application …
Initialising the Ethernet Module …
Ethernet cable is not connected! Waiting …
Ethernet cable is not connected! Waiting …
Ethernet cable is connected!
Enabling DHCP …
Network settings:
IP Address: 192.168.0.120
Subnet Mask: 255.255.255.0
Default Getway: 192.168.0.1
DNS Server:192.168.0.21
Loading the Configuration …
SD Card found
Initialising the PINS …
Initialisation Completed
Updating reading on pin 0
Reading: 155
Sending reading to the server …
Server URI: http://192.168.0.61/WMWebClient/SiteComms/ProbeReading.aspx?SiteData=SiteName=Test+Site;ProbeType=1;ProbeReading=155
#### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) ####
#### Message:
#### GHIElectronics.NETMF.Net.W5100::RegisterWrite [IP: 0015] ####
#### GHIElectronics.NETMF.Net.SocketNative::close [IP: 0007] ####
#### GHIElectronics.NETMF.Net.SocketNative::socket [IP: 0096] ####
#### GHIElectronics.NETMF.Net.Sockets.Socket::.ctor [IP: 002a] ####
#### GHIElectronics.NETMF.Net.HttpWebRequest::EstablishConnection [IP: 0132] ####
#### GHIElectronics.NETMF.Net.HttpWebRequest::SubmitRequest [IP: 0013] ####
#### GHIElectronics.NETMF.Net.HttpWebRequest::GetResponse [IP: 000c] ####
#### CSIR.WaterMonitoring.FezWindow.WMServerComms::SendReading [IP: 00fa] ####
#### CSIR.WaterMonitoring.FezWindow.WMProbeData::UpdateReading [IP: 005d] ####
#### CSIR.WaterMonitoring.FezWindow.WMStart::Main [IP: 00e5] ####
#### Exception GHIElectronics.NETMF.Net.WebException - 0x00000000 (1) ####
#### Message:
#### GHIElectronics.NETMF.Net.HttpWebRequest::GetResponse [IP: 00d3] ####
#### CSIR.WaterMonitoring.FezWindow.WMServerComms::SendReading [IP: 00fa] ####
#### CSIR.WaterMonitoring.FezWindow.WMProbeData::UpdateReading [IP: 005d] ####
#### CSIR.WaterMonitoring.FezWindow.WMStart::Main [IP: 00e5] ####
A first chance exception of type ‘GHIElectronics.NETMF.Net.WebException’ occurred in GHIElectronics.NETMF.W5100.Http.dll

I would really appreciate some help on what is going wrong and if I am doing something incorrectly.


#2

Please use code tags so we can read your code easier. I modified your post.

You are using the wrong libraries. Do not use W5100 and GHI’s networking libraries, those are for smaller devices based on USBizi. You have a device based on EMX so you have full and complete networking support.

Look at the examples that ship with Microsoft NETMF SDK