Error from Dns.GetHostName

M

MSNews

I get the following exception when calling Dns.GetHostName (from C#):
An unhandled exception of type 'System.Net.Sockets.SocketException' occurred
in system.dll
Additional information: An operation on a socket could not be performed
because the system lacked sufficient buffer space or because a queue was
full

This exception is then followed with the following exception:
An unhandled exception of type 'System.TypeInitializationException' occurred
in system.dll
Additional information: The type initializer for "System.Net.Sockets.Socket"
threw an exception.

I'm running .net Framework1.1 on Win2k, on a laptop with a couple of
network adapters. I did some experiments to limit numbers of processes
running, stopped sql server etc... I removed the Netbeui protocol from the
adapter that is connected to the internet etc. I had some success with this
approach... the error disappeared for a couple of days, but is now back.

Any suggestions?
 
J

Jim Blizzard [MSFT]

Thomas,

I've seen something similar to what you're describing.

Does this happen when you run your program for some period of time or does
it happen immediately (right when you start it)?

Also, after you get the error, please run "netstat -a" from the command
line and see if you have a bunch of TCP ports that have a State of
"TIME_WAIT".

Thanks,
bliz

--
Jim Blizzard | http://weblogs.asp.net/jblizzard
Sr .NET Developer Evangelist
Microsoft

Your Potential. Our Passion.

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only, so that others may benefit. Thanks.


--------------------
 
J

Jim Blizzard [MSFT]

Hmmmm. The case I had occured after the program had been running for 30+
hours. It wasn't an immediate thing. There were 100s of ports open in
TIME_WAIT state when it finally failed.

Do you have some simple code you could post that reproduces the problem?

--
Jim Blizzard | http://weblogs.asp.net/jblizzard
Sr .NET Developer Evangelist
Microsoft

Your Potential. Our Passion.

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only, so that others may benefit. Thanks.


--------------------
 
T

Tom Pastusak

I created the simplest of windows forms app, and put a
call to Dns.GetHostName(); in the constructor:
In form1 constructor:
Dns.GetHostName();

I tried some variations
IPHostEntry host = Dns.Resolve
(Environment.MachineName);

In fact, any static method on Dns will give the same
result. It appears to me that the static initializers in
Dns are failing, because if I catch the exception and then
follow up with another call to any Dns static, I get
slightly different behaviour in that the debugger doesn't
report an "uncaught exception in System.dll", but does
report the final exception:
The type initializer for "System.Net.Sockets.Socket" threw
an exception.

In my latest test, there were 0 sockets in the TIME_WAIT
state. There were a total of about 20 TCP sockets listed
in netstat -a. There were about 20 UDP sockets as well.

This result may indicate that there is something peculiar
with my system environment... combination of types of
devices/drivers and protocols that may be tripping up the
Dns initializer? One device I have installed is a Linksys
Combo PCMCIA Ethernet Adapter. I run NetBEUI to
communicate with a shop floor device on 10-baseT.
However, as an experiment, I tried disabling the device
and removing it from my system, and this did not clear up
the problem. Early last week, I had a positive result
with both network devices plugged in and communicating.

Could it be that plug-and-play, with the way in which
adapter numbers are not pre-determined may have laid out
the adapter order in a different sequence, and this leads
to pseudo-random failures?
 
J

Jim Blizzard [MSFT]

Hi Thomas,

Wow. Unfortunately I can't re-create the error you're seeing and don't
know how to assist you in resolving the problem.

Perhaps someone else in this newsgroup can?

Sorry,
bliz

--
Jim Blizzard | http://weblogs.asp.net/jblizzard
Sr .NET Developer Evangelist
Microsoft

Your Potential. Our Passion.

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only, so that others may benefit. Thanks.


--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top