my app is invisible?

Hi

I recoded a console server app to a form server app.

I can run it and it works, but nothing shows. I cant see the form with my textbox in it that shows the log, so the entire app is invisible to me.

Here is the code:

Form1(only has a textbox in it for the moment)

Imports System.Net.sockets

PublicClass Form1

Const portnoAsInteger = 500

Dim localaddAs System.Net.IPAddress = System.Net.IPAddress.Parse("192.168.1.2")

Dim listenerAsNew TcpListener(localadd, portno)

PrivateSub Form1_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)HandlesMyBase.Load

listener.Start()

WhileTrue

Dim userAsNew chatclient(listener.AcceptTcpClient)

EndWhile

EndSub

EndClass

Class Chatclient:

--

Imports System.Net.sockets

PublicClass Chatclient

PublicShared allclientsAsNew Hashtable

Private _clientAs TcpClient

Private _clientipAsString

Private _clientnickAsString

Private data()AsByte

Private receivenickAsBoolean =True

PublicSubNew(ByVal clientAs TcpClient)

_client = client

_clientip = client.Client.RemoteEndPoint.ToString

allclients.Add(_clientip,Me)

ReDim data(_client.ReceiveBufferSize)

_client.GetStream.BeginRead(data, 0,CInt(_client.ReceiveBufferSize),AddressOf receivemessage,Nothing)

EndSub

PublicSub sendmessage(ByVal messageAsString)

Try

Dim nsAs System.Net.Sockets.NetworkStream

SyncLock _client.GetStream

ns = _client.GetStream

EndSyncLock

Dim bytestosendAsByte() = System.Text.Encoding.ASCII.GetBytes(message)

ns.Write(bytestosend, 0, bytestosend.Length)

ns.Flush()

Catch exAs Exception

Form1.txtMessages.AppendText(ex.ToString)

EndTry

EndSub

PublicSub receivemessage(ByVal arAs IAsyncResult)

Dim bytesreadAsInteger

Try

SyncLock _client.GetStream

bytesread = _client.GetStream.EndRead(ar)

EndSyncLock

If bytesread < 1Then

allclients.Remove(_clientip)

Broadcast(_clientnick &" is uitgelogd")

ExitSub

Else

Dim messagereceivedAsString = System.Text.Encoding.ASCII.GetString(data, 0, bytesread)

If receivenickThen

_clientnick = messagereceived

broadcast(_clientnick &" is ingelogd")

receivenick =False

Else

broadcast(_clientnick &": " & messagereceived)

EndIf

EndIf

SyncLock _client.GetStream

_client.GetStream.BeginRead(data, 0,CInt(_client.ReceiveBufferSize),AddressOf receivemessage,Nothing)

EndSyncLock

Catch exAs Exception

allclients.Remove(_clientip)

broadcast(_clientip &" is uitgelogd")

EndTry

EndSub

PublicSub Broadcast(ByVal messageAsString)

Form1.txtMessages.AppendText(message)

Dim cAs DictionaryEntry

ForEach cIn allclients

CType(c.Value, Chatclient).sendmessage(message & vbCrLf)

Next

EndSub

EndClass

-

Can anyone tell me what I can do about it to fix it or what I did wrong?

Bye and thanks in advance.

[11839 byte] By [SnakeSV] at [2007-12-21]
# 1

In your project. what is the startup object.

Sure I see a class form1 but did you create a windows form with you application of just create a class called form1 as there are a number of normally hidden files in 2005 which generate additional code for this class - the part you are seeing is just a partial class.

If you create another form for the project using the IDE and then set this as the startup project does this show when the app is started.

spotty at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2

Your form will never exit the form load event. You created an endless loop. Never use while true the loop will never end

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

listener.Start()

While True

Dim user As New chatclient(listener.AcceptTcpClient)

End While

End Sub

KenTucker at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3

"Never use while true the loop will never end"

Especially in the form load event which is why your form is invisible. It never paints itself.

ReneeC at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...