Thursday, June 28, 2007

Pay attention while you design dot NET Remoting running via a Windows Service

Aaah, I am having hard time nailing down issues, when a windows service is running my remoted server. The client could not connect to the server. Tried different forums including MSDN forums and could not find out whats going on. May be I did not understand the whole concept properly. So all i wanted to say is pay more attention while you wanted some kind of design like this. This is killing me !!!

Initially I had a remoted server using a remoting infrastructure and the client is able to connect, everything is fine. But when the remoted server and the remoting infrastructure are wrapped inside a Windows service, I could not get things working. The client disappoints me by not connecting and throws .NET remoting exceptions. OK to brief on remoting, we might have heard about the good old (D)COM this is now upgraded significantly and made easier with .NET framework, though .NET 1.1 had issues (lot of them) the framework beginning with .NET 2.0 (take a look @ .NET framework - click here) major issues has been resolved. Essentially remoting allows you to talk to objects beyond the boundaries such as application domains/process boundaries, be it the server is running in the same machine or different.
Remoting channels, usually in the form of HTTP, Binary format and IPC. MarshalByRefObject - objects that are derived from this base class complies with remoting, basically they could be remoted. Now remoting infrastructure provides you various ways of using the remoted objects singleton, reference etc.
Now coming to windows Service, there are lots of things you can do by using the windows service. A service is basically a background process, (Go to command prompt, type services.msc, you can get a display of all the services that are listed) which could do several tasks in the background. Why would you want to go for a service, say in my case I wanted to allow multiple clients to connect to my service (which runs the remoted server), do some custom actions when windows starts/shut down/reboot, make such that on Vista ,we could create gadgets and deploy them based on this service. The service could be started, stopped, paused and also the service installation could be based on various security levels whether to be installed for a user/admin/local system. Remember you have to provide impersonation level appropriately to make it run by the desired user groups.

No comments: