Static methods can not be called remotely

Static methods can not be called remotely

 


The client application can not access to static methods / properties / fields remotely. Since you access a static method using CLASSNAME.STATICMETHOD, instead of OBJREF.STATICMETHOD, there’s no proxy involved. So access to static methods always takes place in the client’s context.

 

But you can add a thin non-static wrapper around each static method in order to remote calling.

 

Take the following code snippet as an example:

public class MyClass : MarshalByRefObject

 {

   public static void DoSomething (...) // Can not be called remotely

   {

     ...

   }

 

   public void DoSomethingWrapper (...) // Can be called remotely

   {

     DoSomething (...);

   }

 }

 


 Refer to the articles as follows to get more information:

1. 深度探索.Net Remoting基础架构
http://www.cnblogs.com/rickie/archive/2004/10/22/55292.html
2. 尝试RemotingSqlHelper的若干问题,
http://www.cnblogs.com/rickie/archive/2004/10/13/51500.html


 

 

 

原文地址:https://www.cnblogs.com/rickie/p/757628.html