Vs compile Windows Services and call WebService

Source: Internet
Author: User
  1. You cannot use system. Windows. Forms. timer to call timer. Instead, use system. Timers. Timer.
  2. System. Timers. Timer T = new system. Timers. Timer (interval); // instantiate the Timer class and set the interval to 10000 milliseconds;
    T. elapsed + = new system. Timers. elapsedeventhandler (tick); // execute the event at the time of arrival;
    T. autoreset = true; // set whether to execute once (false) or always execute (true );
    T. Enabled = true; // whether to execute the system. Timers. Timer. elapsed event ;\
  3. Timer function subject
    Public void tick (Object source, system. Timers. elapsedeventargs E)
    {
    String machinename = DNS. gethostname ();
    Localhost. Service ipservice = new myservice. localhost. Service ();
    String status = ipservice. addvalue (machinename, IPS); // call WebService
    }
  4. Right-click the project and choose add web reference. Find WebService.
  5. There are nodes in APP. config. modify them.
  6. <Applicationsettings>
    <Myservice. properties. Settings>
    <Setting name = "myservice_localhost_service" serializeas = "string">
    <Value> http: // localhost/mywebservice/service. asmx </value>
    </Setting>
    </Myservice. properties. Settings>
    </Applicationsettings>
  7. Find service1.cs, right-click the design window, and choose "add installation ".Program"
  8. The servicename of serviceinstaller1 is the installed Service.
  9. Change the account of serviceprocessinstaller1 to LocalSystem.
  10. Start-run-CMD and enter the command "cd c: \ WINDOWS \ Microsoft. NET \ framework \ v2.0.50727 ",
  11. Enter the command "installutil.exe installation path \ myservice.exe"
  12. In the service, you can see the Windows service you have written. Right-click the service and choose "Modify auto run" or "manually run ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.