Under what conditions will `RealProxy.GetTransparentProxy()` return `null`?
Asked Answered
K

1

18

The documentation at http://msdn.microsoft.com/en-us/library/system.runtime.remoting.proxies.realproxy.gettransparentproxy%28v=VS.100%29.aspx doesn't indicate a scenario where GetTransparentProxy will return null, but I'm getting a null back when I call it.

What circumstances will cause this behavior?

Keever answered 23/12, 2010 at 17:37 Comment(0)
K
29

Nevermind, solved it. Its critical to have your RealProxy derived class call the base constructor with the type to be proxied. In my case:

public class MyProxy<T> : RealProxy
{
    public MyProxy()
        : base(typeof(T))    // this was missing
    {
        ...
    }

    ...
}
Keever answered 23/12, 2010 at 17:50 Comment(1)
I just hit into this issue all over again today. Note to anyone else with this issue -- Microsoft .NET returns null, but Mono throws an exception.Keever

© 2022 - 2024 — McMap. All rights reserved.