System.Net.Sockets.SocketException:Could not find resource assembly

Hi everyone,

I have developped a small app for ipaq, windows ce (for which I have installed .Net Compact Framework runtime SP2). The app is very simple, it connects to a url via System.Net.Sockets.TcpClient and retrieves a html web page.

Strangely enough, it works on the Emulator however when I deploy it on the ipaq, I get:

System.Net.Sockets.SocketException:Could not find resource assembly

then

System.Net.Sockets.SocketException
Could not find resource assembly
Dns:GetHostBy Address+0x63
Is something missing, not installed, on the ipaq? (internet connection is working, etc)

Regards,
radu

[624 byte] By [raduvv] at [2007-12-16]
# 1
The "Could not find resource assembly" bit indicates that you have not deployed System.SR assembly that contains the exception descriptions.

It gives you the name of the method that failed: Dns.GetHostByAddress so look it up:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetdnsclassgethostbyaddresstopic2.asp

You can see what exceptions the method can throw and you actually know that you have a SocketException so, reading the documentation: "An error was encountered when resolving the address".

At this point, whether you are calling that method directly or whether it is called as a result of other call you make, the best thing is to show us some code and make sure that whatever address you are passing to TcpClient is reachable.

You can help yourself by catching the SocketException and querying its other helpful properties:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetsocketssocketexceptionmemberstopic.asp

Just fyi, if you browse the netcf assembly which contains the Dns class and have a look at the IL for the method in question (using ILDASM or Reflector etc) then you can go to the line 0x63 and then you'll see that it is the call to the native getgostbyaddr that returned null.

Cheers
Daniel

DanielMoth at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2
Thanks for your answer, I will give it a try

Regards,
radu

raduvv at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 3
Ok, still getting error and it is strange

Here is the code I'm using

try

{

string hostname = "196.25.14.210";

TcpClient client = new TcpClient(hostname, 80);

NetworkStream stream = client.GetStream();

String HttpHeader = String.Format("GET http://{0} HTTP/1.1\r\nHost: {0}\r\n Connection: close\r\n\r\n", hostname);

stream.Write(Encoding.ASCII.GetBytes(HttpHeader), 0, HttpHeader.Length);

byte[] buffer = new byte[10000];

int nRead = stream.Read(buffer, 0, 10000);

client.Close();

System.Windows.Forms.MessageBox.Show(Encoding.ASCII.GetString(buffer, 0, nRead));

}

catch(Exception exc)

{

MessageBox.Show(exc.ToString());

}

If i run the above code with the dotted decimal address, it gives me a SocketException

If I replace hostname = www.google.com, it works nicely, returning me the HTTP 200 OK response

Any ideas on this one ?

Regards, radu

raduvv at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 4
Ok, problem solved !

Dns.Resolve works for urls, IPAddress.Parse will convert dotted decimal to an IPAddress

Thanks to all that read and answered this one,
Regards,
radu

raduvv at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...