我有一个类在通过 .Net 远程处理被远程调用时需要有不同的行为。如果是这种情况,我如何在类(class)内部确定?
class RemoteClass : MarshalByRefObject
{
public void SomeMethod ()
{
if (ConditionWhatINeed) //If this method was called internally/remotely
{
//Do one stuff
}
else
{
//Do another suff
}
}
最佳答案
您可能想看看 RemotingServices.IsObjectOutOfContext Method .它还有一个您可能会觉得有用的示例。当远程处理时的上下文(PS 这是我帐户上未经验证的假设)。另一个有用的助手可能是 RemotingServices.IsTransparentProxy Method .
关于c# - 在.NET Remoting 中如何知道类方法是在内部调用还是远程调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7633412/