| 网站首页 | VB.Net实例分析 | .Net技术文摘 | 下载中心 | VB.Net书籍笔记 | .Net源码 | VBS脚本与组件调用 | Windows2008技术文摘 | 给我们留言 | 
最新公告:

  没有公告

您现在的位置: 乐博网 >> VB.Net实例分析 >> 实例学习笔记 >> 实例分析正文
最新推荐 更多内容
TCP远程连接服务端(VB2010实例)
TCP远程连接服务端(VB2010实例)
作者:Akyao    来源:乐博网收集     更新时间:2011-2-26

如果你想下载本文的源代码RAR压缩集合包  请访问
VB2010源代码集合包(芋头糕)    http://www.lob.cn/code/utility/2795.shtml
特别感谢网友 芋头糕 将此资源提供乐博网分享

TCP远程连接服务端实例代码如下:

Imports System.IO
Imports System.Runtime.Remoting

Public Class MainForm
    ' This function iterates through all the ClientActivatedService types
    ' that were loaded via the RemotingConfiguration.Configure(Remoting.config)
    ' file.
    Private Sub ListClientActivatedServiceTypes()
        Dim entry As ActivatedServiceTypeEntry
        For Each entry In RemotingConfiguration.GetRegisteredActivatedServiceTypes()
            Me.lstOutput.Items.Add("Registered ActivatedServiceType: " & entry.TypeName)
        Next
    End Sub

    ' This function iterates through all the WellKnownService types
    ' that were loaded via the RemotingConfiguration.Configure(Remoting.config)
    ' file.
    Private Sub ListWellKnownServiceTypes()
        Dim entry As WellKnownServiceTypeEntry
        For Each entry In RemotingConfiguration.GetRegisteredWellKnownServiceTypes()
            Me.lstOutput.Items.Add(entry.TypeName & " is available at " & entry.ObjectUri)
        Next
    End Sub

    Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            'Read in Host.exe.config file
            'The call to RemotingConfiguration.Configure loads in the xml configuration file
            'and lets the remoting architecture know what types to make available via remoting
            Me.lstOutput.Items.Add("Loading Activated Configuration File")

            RemotingConfiguration.Configure("Host.exe.config", False)

            'After loading the remoting.config file enumerate the list of ClientActivated
            'types and WellKnown types and list them in the list box on the form.
            Me.ListClientActivatedServiceTypes()
            Me.ListWellKnownServiceTypes()

        Catch exp As Exception
            ' Will catch any generic exception
            Dim txt As String
            txt = "I was unable to load the file remoting.config or it is not in the correct format." & vbCrLf & _
             "Please make sure it is located in the same directory as this exe " & _
             " and that it is in the correct format." & vbCrLf & _
             "Please see the Help, About box for the location of this exe." & vbCrLf & vbCrLf & _
             "Detailed Error Information below:" & vbCrLf & vbCrLf & _
             "  Message: " & exp.Message & vbCrLf & _
             "  Source: " & exp.Source & vbCrLf & vbCrLf & _
             "  Stack Trace:" & vbCrLf & _
             exp.StackTrace

            MessageBox.Show(txt, "Generic Exception", MessageBoxButtons.OK, MessageBoxIcon.Stop)

            Me.lstOutput.Items.Add("Unabled to load objects.")
        End Try

    End Sub


End Class

  • 上一篇:

  • 下一篇:
  • 【字体: 】【打印此文】【关闭窗口
      相关文章:(只显示最新16条)
    读取大文件(VB2010实例)
    读取文件(VB2010实例)
    文件移动(VB2010实例)
    获取驱动器磁盘信息(VB2010实例)
    目录搜索和目录查找(VB2010实例)
    文件搜索和文件查找(VB2010实例)
    选择文件目录(VB2010实例)
    删除文件(VB2010实例)
    复制文件(VB2010实例)
    复制目录(VB2010实例)
    DateTime(VB2010实例)
    arrays(VB2010实例)
    APICalls(VB2010实例)
    DataComboBox(VB2010实例)
    创建数据库(VB2010实例)
    ThreadUIUpdate(VB2010实例)

    | 设为首页 | 加入收藏 | 联系站长 | | 友情链接 | 版权申明 |
    乐博网欢迎各种媒体转载我们的原创作品[转载请注明出处];我们鼓励更多VB.Net开发者一起加入研究与探讨;如发现文章访问错误、内容错误或版权疑问、内容有违相关法律(如涉及政治、色情、反动或散布虚假有害信息)等情况,请及时向我们举报,我们将及时纠正!
    联系邮箱:Shiny#vip.qq.com (#替换为@) QQ交流群: 40797788 [闽ICP备05014267号]