Reputation: 17186
In other words, how do I tell if I have a reference to a TransparentProxy or a local object?
Upvotes: 2
Views: 1078
Reputation: 3374
Take a look at the IsTransparentProxy method found in RemotingServices.
Upvotes: 5
Reputation: 44931
Try this fun little trick:
bool fIsTransparentProxy = ((myTransparentObject as MarshalByRefObject) == null);
When I attempted to convert a transparent proxy to MarshalByRefObject, it returned null. I tested this in VB, since that's where all my proxies are, but hopefully the same behavior holds true in C#.
Also note that Visual Studio debugger knows which is which, but I couldn't figure out how to get code that produces the same results (hovering over a TP object in VS shows System.Runtime.Remoting.Proxies.__TransparentProxy
as the class type, but this is an internal sealed class).
Upvotes: 0