Mega Code Archive

 
Categories / C# / Development Class
 

Uses an object in another application domain

/* Mastering Visual C# .NET by Jason Price, Mike Gunderloy Publisher: Sybex; ISBN: 0782129110 */ /*   Example18_3.cs uses an object in another application domain */ using System; using System.Runtime.Remoting; using System.Reflection; public class Example18_3  {   public static void Main()    {     // create a new appdomain     AppDomain d = AppDomain.CreateDomain("NewDomain");          // load an instance of the System.Rand object     ObjectHandle hobj = d.CreateInstance("Example18_2", "SimpleObject");     // use a local variable to access the object     SimpleObject so = (SimpleObject) hobj.Unwrap();     Console.WriteLine(so.ToUpper("make this uppercase"));   } } //================================================= /*   Example18_2.cs defines a simple object to create */ using System; [Serializable] public class SimpleObject  {   public String ToUpper(String inString)   {     return(inString.ToUpper());   } }