Execute code in another application domain : AppDomain « Reflection « VB.Net Tutorial






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








19.7.AppDomain
19.7.1.Use ExecuteAssembly on two different domains.
19.7.2.Execute code in another application domain
19.7.3.Use the SetData(String, Object) method to create a new value pair