我有一个 {System.Runtime.Remoting.Proxies.__TransparentProxy} 类型的运行时对象,它是从继承自 ContextBoundObject 的类的实例创建的。此类向其他对象引发事件,我需要将此代理对象转换为原始对象。所有对象都在单个系统上的默认 AppDomain 中。
public abstract class ObjectBase : ContextBoundObject, IObjectBase
{
}
public IMessageSink GetObjectSink(MarshalByRefObject o, IMessageSink next)
{
_context = (ObjectBase)o;// as ObjectBase; does not give any error but type remains
/// transparent proxy in VS watch window.
// no property to get the underlying type of the proxy
return _aspect;
}
如何将它们转换为原始对象?如果在同一内存上运行,为什么会创建代理