在什么条件下`RealProxy.GetTransparentProxy()`返回`null`?

Dav*_*fer 16 .net c# proxy-classes realproxy

http://msdn.microsoft.com/en-us/library/system.runtime.remoting.proxies.realproxy.gettransparentproxy%28v=VS.100%29.aspx上的文档未指明GetTransparentProxy将返回的方案null,但是null当我打电话给我时我会回来的.

什么情况会导致这种行为?

Dav*_*fer 27

没关系,解决了.它的关键有你的RealProxy派生类中调用基类的构造与被代理的类型.就我而言:

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

    ...
}
Run Code Online (Sandbox Code Playgroud)