Obtain an instance of a windows service in .NET

I wrote a windows service using c#.  It communicates with my application using .net remoting.  I can obtain an instance of my service using .net remoting, however using the methods is too much slower than doing the method within the application.

Is there a way to obtain an instance of the service so I can execute its methods directly?  I know I can get a ServiceController object based on the service name.  Is there a way for my application to get the instance itself, so that I can execute

Or is remoting the only way?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Modify the service to respond to custom messages and use ControlService() to pass them:

lynx2sw1Author Commented:
I had thought those custom message parameters were only integers, without a control value.  I want to pass in other things than intts, a

I am coding in C#.  But I followed your link and it gave me the idea to try to use kernal32 in my c#.  
[DllImport("advapi32.dll", EntryPoint="OpenService")] public static extern int OpenServiceA(int hSCManager, string lpServiceName, int dwDesiredAccess)
Well, yes, you have to use OpenService() to get a handle to the service to tell ControlService() which service's control handler to send the message to.  The value of the message would tell the service which method to call.

Perhaps you could use object serialization for passing data.  If you don't have too many object types to pass, the custom control code could be used to specify both method and object.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.