// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Diagnostics; using System.Reflection; public class Test : MarshalByRefObject { public string dup(string s) { if(isremote()) { Console.WriteLine("Called remote"); } else { Console.WriteLine("Called local"); } return (s + s); } public bool isremote() { StackTrace trace = new StackTrace(true); for(int i = 0; i < trace.FrameCount; i++) { StackFrame frame = trace.GetFrame(i); MethodBase method = frame.GetMethod(); if(method.DeclaringType.ToString().IndexOf("System.Runtime.Remoting.Channels.") == 0) { return true; } } return false; } }