Avoid Loading Unnecessary Assemblies into Application Domains - CSharp Custom Type

CSharp examples for Custom Type:AppDomain

Description

Avoid Loading Unnecessary Assemblies into Application Domains

Demo Code

using System;//from w ww  .ja  v a2s. c o  m
using System.Data;
using System.Runtime.Remoting;
class MainClass{
   public static ObjectHandle WrapDataSet(DataSet ds) {
      ObjectHandle objHandle = new ObjectHandle(ds);
      return objHandle;
   }
   public static DataSet UnwrapDataSet(ObjectHandle handle) {
      DataSet ds = (System.Data.DataSet)handle.Unwrap();
      return ds;
   }
   public static void Main() {
      DataSet ds = new DataSet();
      Console.WriteLine(ds.ToString());
      ObjectHandle oh = WrapDataSet(ds);
      DataSet ds2 = UnwrapDataSet(oh);
      Console.WriteLine(ds2.ToString());
   }
}

Result


Related Tutorials