PC Review


Reply
Thread Tools Rate Thread

System.Net.Sockets.Socket threw an exception

 
 
Aero
Guest
Posts: n/a
 
      3rd Apr 2006
Hi,
My window application written in C# is throwing following exception
while connecting to one FTP location

The type initializer for System.Net.Sockets.Socket threw an exception

This exe is working fine on staging environment, (Window 2003) but
after migrating to production environment (Windows 2000), throwing this
exception at

_clientSocket = new
Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);

- Only three Network cards are installed on production server
- while checking TCP/IP port status , there were few connections at
TIME_WAIT mode. but this might not be the cause for insufficient buffer
space.
- Recenetly we have installed Microsoft.Net\Framework\v1.1.4322

If somehow this is related to buffer space/long que, then how to clear
this and manage for future.

Not getting any idea from where to start. Any idea/suggestion would be
of great help.

Thanks

 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      3rd Apr 2006
Aero <(E-Mail Removed)> wrote:
> My window application written in C# is throwing following exception
> while connecting to one FTP location
>
> The type initializer for System.Net.Sockets.Socket threw an exception


Have you looked at the inner exception of that exception? It should
give more details about what went wrong.

It's very worrying if the type initializer threw an exception though -
that suggests that something is pretty wrong on the machine. (In
particular, it's unlikely to be anything to do with your code.)

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
 
Aero
Guest
Posts: n/a
 
      3rd Apr 2006
Following is the code snippet which is causing the problem.
public void Login()
{
try
{
_clientSocket = new
Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);
-----Error Point
}
catch(Exception Ex)
{
throw new IOException("Message: " + Ex.Message+ "Source:" + Ex.Source+
"Inner Exception" + Ex.InnerException);
}
IPEndPoint remoteEndPoint = new
IPEndPoint(Dns.Resolve(_remoteHost).AddressList[0], _remotePort);

try
{
_clientSocket.Connect(remoteEndPoint);
}
catch(Exception)
{
throw new IOException("Couldn't connect to remote server");
}

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      3rd Apr 2006
Aero <(E-Mail Removed)> wrote:
> Following is the code snippet which is causing the problem.


Rather than a snippet, could you post a short but *complete* program
which demonstrates the problem?

Also, what is the inner exception in this case, if any?

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Aero
Guest
Posts: n/a
 
      4th Apr 2006
Actually Code is too big but i am getting the error at
Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);


Error Message: The type initializer for "Syetem.Net.Sockets.Socket"
threw an exception
Error Source: System.Net.Sockets.SocketException
Inner Exception An operation on a socket sould not be
performed because the system lacked sufficient buffer space or because
a queue was full
at System.Net.Sockets.Socket.InitializeSockets()
at System.Net.Sockets.Socket..cctor()

Please refer the following Microsoft article
FIX: Socket initialization does not succeed if your computer has more
than 50 network bound protocols
http://support.microsoft.com/?id=826757

Now we are planning to upgrade to Microsoft.Net Framework 2.0 on
production environment and lets see if it works or not.

Please suggest what can we do resolve this ASAP, even we are not sure
that will that work or not....just taking a chance.

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      4th Apr 2006
Aero <(E-Mail Removed)> wrote:
> Actually Code is too big but i am getting the error at
> Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);


The existing code may be too big, but have you tried creating a sample
program just for the sake of pinning down the error?

> Error Message: The type initializer for "Syetem.Net.Sockets.Socket"
> threw an exception
> Error Source: System.Net.Sockets.SocketException
> Inner Exception An operation on a socket sould not be
> performed because the system lacked sufficient buffer space or because
> a queue was full
> at System.Net.Sockets.Socket.InitializeSockets()
> at System.Net.Sockets.Socket..cctor()
>
> Please refer the following Microsoft article
> FIX: Socket initialization does not succeed if your computer has more
> than 50 network bound protocols
> http://support.microsoft.com/?id=826757
>
> Now we are planning to upgrade to Microsoft.Net Framework 2.0 on
> production environment and lets see if it works or not.
>
> Please suggest what can we do resolve this ASAP, even we are not sure
> that will that work or not....just taking a chance.


Well, have you read the article it referenced?

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Aero
Guest
Posts: n/a
 
      6th Apr 2006
Hi,
I am not able to simulate this problem in any of our environments. This
is occuring only on production server.
I tried a sample code there and again it gave the same error.
While investigating we found that production server has .Net framework
1.1.4322 installed without service pack 1.
Now we are assuming that this might be the problem and today we are
going to upgrade this to .Net Framework 2.0.50215
Lets see what happens. If it works fine then its OK otherwise i'll have
think in different direction.
Thanks for your valuable inputs.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Server threw an exception =?Utf-8?B?WWFuaQ==?= Windows XP Internet Explorer 0 6th Dec 2004 07:33 PM
Server threw an exception error message =?Utf-8?B?Qi5CYWlsZXk=?= Windows XP Help 4 29th Oct 2004 10:25 AM
Server threw an exception error message. =?Utf-8?B?Qi5CYWlsZXk=?= Windows XP General 2 17th Oct 2004 11:43 PM
Error: The server threw an exception Tracey Kellicutt Windows XP Internet Explorer 1 26th Jun 2004 03:04 PM
The Server Threw an Exception Jitendra Jadav Windows XP Internet Explorer 1 17th Jun 2004 10:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:44 PM.