RJKSolutions

OnDisconnect event in .Net

Discussion created by RJKSolutions on Sep 2, 2009
Latest reply on Oct 20, 2009 by RJKSolutions

Was asked a question to which I could not find a comprehensive answer.
I am hoping vCampus can provide that answer

 

For the OnDisconnect event, PISDK details the interface IServerDisconnect is to be used to get access to the event.

 

Here is the code for VB6/VBA from the manual:


Option Explicit
Dim WithEvents srvdisc As ServerDisconnectEvents
Dim srv As Server

Private Sub Command1_Click()   
Set srv = Servers.DefaultServer   
Dim isrvdis As IServerDisconnect   
Set isrvdis = Servers   
Set srvdisc = isrvdis.DisconnectEvents
End Sub

Private Sub Command2_Click()      
srv.Open      srv.Close
End Sub

Private Sub srvdisc_OnDisconnect(ByVal pServer As PISDK.Server)      
MsgBox "disconnected from " + pServer.Name
End Sub



The above works great.

Now try the equivalent code in .Net using the interops and it fails saying "No Such Interface" for IServerDisconnect!?

 

After some headsratching we found that using the following does work but wonder why the interface IServerDisconnect does not work using the interop?


_DServerDisconnectEvents_Event srvdisevt = (_DServerDisconnectEvents_Event) _piSDKServer; // Using IServerDisconnect here fails.

srvdisevt.OnDisconnect += srvdisevt_OnDisconnect;


Rhys.

Outcomes