views:

42

answers:

1

Why something like following is not allowed. I mean why the following method will not be exposed in the web service.

 [WebMethod]

public static string Foo()

{

    return "bar";

}

It will be great if you can provide me a non language specific high level answer rather than something like "Proxy Objects can not call static methods".

+2  A: 

The web server could serve requests for your web service with multiple instances simultaneously. These could be split into multiple processes, so any kind of shared state in memory would not be desirable. While this is not a strong argument, it could explain why the designers of the framework did not want to encourage thinking of these methods as static.

Jeff Katz
I buy your argument partially. Static variables are shared among the objects in a install process. If you spawn 2 processes the static data is not really shared isnt it?
Akshar Prabhu Desai