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


 

 

 

posted @ 2007-05-23 21:17  Rickie  阅读(1197)  评论(1编辑  收藏  举报