MarshalByRefObject access objects across application domain : Serialize Object « File Directory « VB.Net






MarshalByRefObject access objects across application domain

 


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 

   
  








Related examples in the same category

1.Serialize Data to Binary and XML at the same time
2.Serialize Object to XML Stream and output to screen
3.Save Serializable Object to binary file: create a sequential-access file
4.Serializable Person Object
5.Serialize to Xml
6.Simple Serializable Person Object