【问题标题】:'TcpListener' is ambiguous in the namespace 'System.Net.Sockets'“TcpListener”在命名空间“System.Net.Sockets”中不明确
【发布时间】:2012-02-21 10:55:42
【问题描述】:

我的 VB 程序中有 11 个错误。所有错误看起来都相似:X 在命名空间 Y 中不明确

错误行:导入 System.Net.Sockets 导入 System.Text 模块模块1 子主()
Dim serverSocket As New TcpListener(System.Net.IPAddress.Parse("192.168.1.100"), 8888)

我该如何解决这个问题?

【问题讨论】:

    标签: vb.net tcplistener


    【解决方案1】:

    我怀疑您为定义System.Net.Sockets 的程序集添加了两个不同的引用。 (对于 .NET 2.0 和 .NET 4.0,可能是 System.dll,但这既不是这里也不是那里。)

    我这么说是因为there's nothing wrong with your code:

    Imports System.Net.Sockets
    Imports System.Text
    
    Module Module1
    
    Sub Main()
      Dim serverSocket As New TcpListener(System.Net.IPAddress.Parse("192.168.1.100"), 8888)
    End Sub
    
    End Module
    

    result: success time: 0.16s memory: 25064 kB returned value: 0

    【讨论】:

    • 刚才我发现引用“系统”并且上述错误消失了。但是现在又出现了一个错误。 {“请求的地址在其上下文中无效”}
    猜你喜欢
    • 2011-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-28
    • 2014-10-15
    • 2012-05-07
    • 1970-01-01
    • 2021-11-28
    相关资源
    最近更新 更多