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.“
The thing is, I have to declare it as 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
TcpListenerwithout any arguments. What port do you want to listen to, for example?You might want something like:
which should work fine.
This isn’t specific to
TcpListener– you should always consider which arguments you want to pass to a constructor.