OK, this probably is going to be a head-banger, but why is this code not working?
Dim tcplistener As New System.Net.Sockets.TcpListener
This does not compile with the error "Overload resolution failed because no accessible 'New' accepts this number of arguments.
"
New
because otherwise I will get a null-reference exception...
Does anybody know what I am doing wrong, or should do differently?
Thanks!Look at the constructor overloads available. They all have parameters - so you can't just create a TcpListener
without any arguments. What port do you want to listen to, for example?
You might want something like:
Dim tcplistener As New System.Net.Sockets.TcpListener(8080)
which should work fine.
This isn't specific to TcpListener
- you should always consider which arguments you want to pass to a constructor.
精彩评论