Odd AddHandler Exception

Hey guys,

I’m getting a runtime exception on an AddHandler call that states that I’m attempting to add a handler when there’s already been one added already. Problem is, I can’t see where that is happening. Here’s my method where the error happens…

Sub InitializeSplashUploadSocket()

  ImagePushSocket = New ConnectAndWriteSocket
  ImagePushSocket.Address = IPAddress
  ImagePushSocket.Port = 5000
  ImagePushSocket.NetworkInterface = MyNIC
    AddHandler ImagePushSocket.SendProgress, WeakAddressOf UploadImageProgress
  End Try
    AddHandler ImagePushSocket.QueueWriteComplete, WeakAddressOf UploadSplashComplete
  End Try
    AddHandler ImagePushSocket.ConnectFailed, WeakAddressOf UploadSplashConnectFailed
  End Try

    AddHandler ImagePushSocket.SendComplete, WeakAddressOf SplashImageUploadComplete
  End Try
End Sub

The last AddHandler directive is where the exception occurs. The only other place where this handler could have been added is in the constructor of the socket. But that code is:

Sub Constructor()
  ConnectCheckTimer = New Timer
  ConnectCheckTimer.Mode = Timer.ModeOff
  ConnectCheckTimer.Period = 1000
  AddHandler ConnectCheckTimer.Action, WeakAddressOf ConnectCheckTimerAction
  // Calling the overridden superclass constructor.
  // Note that this may need modifications if there are multiple constructor choices.
  // Possible constructor calls:
  // Constructor() -- From TCPSocket
  // Constructor() -- From SocketCore
End Sub

So I am stumped as to what is causing this error…

Is there any way in the debugger to determine the delegate for the event handler so I can see what method has already been assigned?

Does the ConnectAndWriteSocket implement any events that are then reraised ?

Yes. The underlying TCPSocket’s SendComplete event.

And does it define a new SendComplete event that is raised ?
If not thats your problem

Yes. I’ve implemented a new SendComplete event definition

Ack! It was a typo in my event definition signature. I named it