I’ve looked into COM servers and Windows services but I’m not sure what best suits my purposes or how to do it. What I want is something that can be started and run for an indefinite amount of time which holds an object so that other processes or applications obtain references to that object (or make requests to the server) to modify or query its state.
The server is essentially an application which processes commands to a device over a serial port and maintains an internal state of the device.
I have the device communication and persistence functionality written in C# right now and it can be created and run on a per-process basis but obviously I want it to instantiate once and run independently of other processes.
COM tutorials I’ve read have only confused me since I wasn’t entirely sure if that is what I wanted and I was hoping there’d be more of a .Net way to do this.
Any help would be immensely appreciated!
I would build a Windows Communication Foundation (WCF) service for this and expose it with one of the many bindings that is available. You can expose it via HTTP/SOAP, HTTP/REST, TCP/Binary, MSMQ, etc. all from the same service. If you have Windows 2008, you can activate it via Windows Activation Service (WAS). If you have some other Windows OS, you should write a Windows Service that you can register with the Service Control Manager (SCM). There are a lot of options here but I would definitely lean toward using WCF to create your service. There’s so much “plumbing” that WCF takes care of for you. No need to reinvent all of that. Hope this helps.