Imports System
Imports System.Reflection
Public Class Worker
Inherits MarshalByRefObject
Public Sub PrintDomain()
Console.WriteLine(AppDomain.CurrentDomain.FriendlyName)
End Sub
End Class
Class Example
Public Shared Sub Main()
Dim localWorker As New Worker()
localWorker.PrintDomain()
Dim ad As AppDomain = AppDomain.CreateDomain("New domain")
Dim remoteWorker As Worker = CType(ad.CreateInstanceAndUnwrap([Assembly].GetExecutingAssembly().FullName,"Worker"),Worker)
remoteWorker.PrintDomain()
End Sub
End Class