How to pass parameters to Windows Service?

前端 未结 6 2591
猫巷女王i
猫巷女王i 2020-12-16 11:21

I tried to pass parameters to a windows service.

Here is my code snippet:

class Program : ServiceBase
{
    public String UserName { get; set; }
             


        
6条回答
  •  猫巷女王i
    2020-12-16 12:26

    The two cleanest ways to pass arguments (without using registry, files or a database) to a Windows Service at runtime is using Named Pipes or setting up a WCF Service in windows, that your client calls into. By default, a Windows Service is meant to be a repetitive process that runs.

    If you use WCF, turn it on in Add Remove Programs (or Programs and Features for Windows 7).

    Named Pipes:

    https://msdn.microsoft.com/en-us/library/aa365590(v=vs.85).aspx

提交回复
热议问题