Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ee0bc0d176
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 55 lines (46 sloc) 1.494 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
using System;
using System.ComponentModel;
using System.Runtime.Remoting;

namespace Test {
public class Test {
static void Main ()
{
AppDomain domain = AppDomain.CreateDomain ("new-domain");
domain.DoCallBack (Run);
Type stType = typeof (Something<string, string>);
Other<string, string> st = (Other<string, string>) domain.CreateInstanceAndUnwrap (stType.Assembly.FullName, stType.FullName);
Console.WriteLine ("in main int: {0}", st.getInt ());
Console.WriteLine ("in main types: {0}", st.getTypeNames<Test> ());
}

public static void Run ()
{
DoRun<string, string>(new Something<string, string> ());
}

public static void DoRun<T1, T2> (Other<T1, T2> some)
{
Console.WriteLine ("domain: {0}", AppDomain.CurrentDomain.FriendlyName);
Console.WriteLine ("This is null: {0}", some.Mappings == null);
Console.WriteLine ("int: {0}", some.getInt ());
}
}

public class Other<T1, T2> : MarshalByRefObject {
public T2 Mappings {
get { return default(T2); }
}

public virtual int getInt () {
return 123;
}

public virtual string getTypeNames<T3> () {
return "error";
}
}

public class Something<T1, T2> : Other<T1,T2> {
public override int getInt () {
return 456;
}

public override string getTypeNames<T3> () {
Console.WriteLine ("getTypeNames in {0}", AppDomain.CurrentDomain.FriendlyName);
return typeof(T1).ToString () + " " + typeof(T2).ToString () + " " + typeof (T3).ToString ();
}
}
}
Something went wrong with that request. Please try again.