什么情况下`RealProxy.GetTransparentProxy()`会返回`null`?

发布于 2024-10-09 10:46:24 字数 405 浏览 0 评论 0原文

文档位于 http://msdn.microsoft.com/en-us/library/system.runtime.remoting.proxies.realproxy.gettransparentproxy%28v=VS.100%29.aspx 并不表示以下情况: GetTransparentProxy 将返回 null,但当我调用它时,我得到一个 null

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝不服输 2024-10-16 10:46:24

没关系,解决了。让您的 RealProxy 派生类使用要代理的类型调用基本构造函数,这一点至关重要。就我而言:

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

    ...
}

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
    {
        ...
    }

    ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文