[Mono-bugs] [Bug 632316] New: Unexpected NullReferenceException when calling a generic method in a remoting scenario

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Aug 18 08:40:11 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=632316

https://bugzilla.novell.com/show_bug.cgi?id=632316#c0


           Summary: Unexpected NullReferenceException when calling a
                    generic method in a remoting scenario
    Classification: Mono
           Product: Mono: Runtime
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: remoting
        AssignedTo: lluis at novell.com
        ReportedBy: jbevain at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Repro:

<<<<<<<<<
using System;

public sealed class Engine : MarshalByRefObject {

    readonly Context context;

    public Engine ()
    {
        this.context = new FooContext ();
    }

    public TService GetService<TService> () where TService : class, new ()
    {
        return context.Register<TService> ();
    }

    public static Engine CreateRemote (AppDomain domain)
    {
        return (Engine) domain.CreateInstanceAndUnwrap (
            typeof (Engine).Assembly.FullName,
            typeof (Engine).FullName,
            new object [0]);
    }
}

public abstract class Context {

    public abstract TService Register<TService> () where TService : class, new
();
}

public class FooContext : Context {

    public override TService Register<TService> ()
    {
        Console.WriteLine ("Register");

        return new TService ();
    }
}

[Serializable]
public class Program {

    static void Main (string [] args)
    {
        var domain = AppDomain.CreateDomain ("foo");
        var engine = Engine.CreateRemote (domain);

        Console.WriteLine (engine.GetService<Program> () != null);
    }
}
<<<<<<<<<

Results in:

<<<<<<<<<
[mono] /tmp/host5 @ mono test.exe 

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
  at Engine.GetService[Program] () [0x00000] in <filename unknown>:0 
  at Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
<<<<<<<<<

net prints:

<<<<<<<<<
Register
True
<<<<<<<<<

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list