Howto: VB.NET DCOM-Remote access from your own .NET App

This section contains user-submitted tutorials.
Post Reply
User avatar
Senior user
Senior user
Posts: 1688
Joined: 2015-09-26 11:50
Location: Germany

Howto: VB.NET DCOM-Remote access from your own .NET App

Post by Dravion » 2017-07-24 11:06

This is basicly the same Howto as allready described in:

Because its VB.NET (NOT the same as VBScript or VBA! it looks a bit diffrent

See the code below:

Code: Select all

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim tServerType As Type
Dim remoteServer As hMailServer.Application

'Retrieve hMailServer.Application Type info
tServerType = Type.GetTypeFromProgID("hMailServer.Application", ed_server.Text)

'Create an instance of the remote server object locally.
remoteServer = Activator.CreateInstance(tServerType)

'Authenticate against hMailServer
remoteServer.Authenticate(ed_username.Text, ed_password.Text)

'Now we are authenticated, we can operate with hMailServer Service

'Get hMailServers VersionInfo
Dim strhMsVersion As String
strhMsVersion = remoteServer.Version
MessageBox.Show(strhMsVersion, $"Info")

Catch errCom As COMException
MessageBox.Show(errCom, $"Info")
Catch err As Exception
MessageBox.Show($"Error 2 xxxx", $"Info")
End Try
End Sub
Working VS2017 VB.NET Project attached
(66.11 KiB) Downloaded 281 times

Post Reply