| Dart Home | PowerTCP Sockets for .NET | Custom Development | Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums |
| Author | Forum: PowerTCP Sockets for .NET (Secure and Standard) Topic: NullReferenceException |
| timomw From: Helsinki, Finland Posts: 3 Member Since: 01/04/05 |
posted February 8, 2005 7:35 AM Hi, I'm using your Sockets for .Net (Standard) with my server application. Occasionally I get strange NullReferenceExceptions. Here is all I can see in my logs: Exception Name:NullReferenceException Message:Object reference not set to an instance of an object. Source:Dart.PowerTCP.Sockets Stack trace: at Dart.PowerTCP.Sockets.ConnectionEventArgs.get_Tcp() at FICORA.DomainNameProject.WhoIsService.SingletonPowerTCPServer.server1_Connection(Object sender, ConnectionEventArgs e) Do you have any idea what could be the reason for these errors. My application is basically very simple: It listens to a port and when client is connecting it creates a new tcp-object, takes clients input, does a database query, sends the results back to client and closes the connection. Best regards, Timo W |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted February 8, 2005 8:54 AM It sounds like you are referencing an object that has already been set to null. Check to see if e.Tcp = null first and see if the problem goes away. There's no reason that e.Tcp should be null at that point, so if that turns out to be the cause, please describe the exact steps we need to take to duplicate the problem. |
| timomw From: Helsinki, Finland Posts: 3 Member Since: 01/04/05 |
posted February 9, 2005 6:31 AM If e.Tcp is null when server1_Connection event is fired, is it enough just to say return after that (see my example) or how should I 'disconnect' the non-existing connection? private void server1_Connection(object sender, Dart.PowerTCP.Sockets.ConnectionEventArgs e) { if(e.Tcp == null) { WriteToLog("e.Tcp was null"); return; } else { try { Connection conn = new Connection(e.Tcp); conn.Execute(); } catch(Exception ex) { // eat any exceptions WriteToLog("connection error"); } } |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted February 9, 2005 8:52 AM If e.Tcp is null there is nothing to disconnect. As I said previously, it also shouldn't happen, so if you figure out a way to reproduce it, please let us know. |
| Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|