This topic is now archived and is closed to further replies.


VB.NET and DirectPlay8 samples

Recommended Posts

Hi all, I''ve been playing with VB.NET Beta2 SP2 and tried to create my own lobby server using DirectPlay based on the vb_simpleserver sample in the DirectX8 SDK. I am using the vb_simpleclient sample compiled with VB6SP5 to connect and test my server app. When a player connects to my server, I want to add their info to a collection via GetClientInfo - and that''s about it for now Everything seems to be going well, client shows my server program in its list of Enum''d hosts, but when I connect to my server the server throws the following error: "An unhandled exception of type ''System.InvalidCastException'' occurred in Chatterbox.exe Additional information: QueryInterface for interface DxVBLibA.DirectPlay8Server failed." This occurs in the CreatePlayer event (as in DxVBLibA.DirectPlay8Event.CreatePlayer) when I try and perform a GetClientInfo. My code for this event is as follows: --------------------------------------------- Public Sub CreatePlayer(ByVal lPlayerID As Integer, ByRef fRejectMsg As Boolean) Implements DxVBLibA.DirectPlay8Event.CreatePlayer Dim dpPlayerInfo As DxVBLibA.DPN_PLAYER_INFO ''Check if server is started yet (stops getting CreatePlayer from server when starting) If Not gfStarted Then Exit Sub End If ''Log event to listbox lstPlayers.Items.Add("Player attempting connection...") Try ''Get the player info ''ERROR OCCURS HERE!!! dpPlayerInfo = dps.GetClientInfo(lPlayerID) ''Add this player info struct to collection If <> "" Then gcolPlayers.Add(dpPlayerInfo, lstPlayers.Items.Add( & " connected.") End If Catch ''Default catch-all If Err.Number Then lstPlayers.Items.Add("Error: " & Err.Number & "," & Err.Description) Exit Sub End If End Try End Sub --------------------------------------------- Any ideas? Anyone tried converting the DirectPlay samples for use in VB.NET? I know I could use WinSockets in VB.NET, but I wanted to learn about DirectPlay, and I have heard somewhere that DirectX9 will probably (probably being the operative word here include .NET-enabling. The error itself sort of looks like a problem with the DirectX8 for Visual Basic library and the way VB.NET is calling it... Thanks! Blighty

Share this post

Link to post
Share on other sites