title: Calling custom methods on windows service
body: <p>How can i call custom method on a windows service:</p>
  
  <pre><code>public class TestService:ServiceBase
  {
     public TestService()
     {
        // constructor
     }
  
   protected override void OnStart(string[] args)
   {
      // do some work here
   }
  
   protected override void OnStop()
   {
      // do some work here
   }
  
   public void TestMethod(int arg)
   {
       // do some work here
   }
  }
  </code></pre>
  
  <p>I know that name of the service is "TestService", so i can do the following:</p>
  
  <pre><code>ServiceController sc = new ServiceController("TestService");
  </code></pre>
  
  <p>But if I do the following, it doesn't work</p>
  
  <pre><code>sc.TestMethod(5);       // cannot do this
  </code></pre>
  
  <p>How can i access a method on the service? I am using c#</p>
  
  <p>Thanks.</p>