CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
typeof (CrossDomain).Assembly.FullName, "CrossDomain");
+ domains_print_across (o);
+
domains_2 (o, new CrossDomain ());
o.invoke_2 ();
public static void domains_2 (object o, object o2) {
}
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static void domains_print_across (object o) {
+ }
+
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void domains_3 () {
}
class TypeLoadClass2 {
}
+public class SentinelClass : MarshalByRefObject {
+}
+
public class CrossDomain : MarshalByRefObject
{
+ SentinelClass printMe = new SentinelClass ();
+
public void invoke () {
Tests.invoke_in_domain ();
}
ex.InvokeMethod (e.Thread, tostring_method, null, InvokeOptions.SingleThreaded);
}
+ [Test]
+ public void MemberInOtherDomain () {
+ vm.Detach ();
+
+ Start (new string [] { "dtest-app.exe", "domain-test" });
+
+ vm.EnableEvents (EventType.AppDomainCreate, EventType.AppDomainUnload, EventType.AssemblyUnload);
+
+ Event e = run_until ("domains_print_across");
+
+ var frame = e.Thread.GetFrames ()[0];
+ var inOtherDomain = frame.GetArgument (0) as ObjectMirror;
+ var crossDomainField = (ObjectMirror) inOtherDomain.GetValue (inOtherDomain.Type.GetField("printMe"));
+ Assert.AreEqual ("SentinelClass", crossDomainField.Type.Name);
+ }
+
[Test]
public void Domains () {
vm.Detach ();
return err;
MonoClass *obj_type;
+ gboolean remote_obj = FALSE;
obj_type = obj->vtable->klass;
- if (mono_class_is_transparent_proxy (obj_type))
+ if (mono_class_is_transparent_proxy (obj_type)) {
obj_type = ((MonoTransparentProxy *)obj)->remote_class->proxy_class;
+ remote_obj = TRUE;
+ }
g_assert (obj_type);
buffer_add_value (buf, f->type, val, obj->vtable->domain);
g_free (val);
} else {
- buffer_add_value (buf, f->type, (guint8*)obj + f->offset, obj->vtable->domain);
+ guint8 *field_value = NULL;
+ void *field_storage = NULL;
+
+ if (remote_obj) {
+ field_value = mono_load_remote_field(obj, obj_type, f, &field_storage);
+ } else
+ field_value = (guint8*)obj + f->offset;
+
+ buffer_add_value (buf, f->type, field_value, obj->vtable->domain);
}
}
break;