none
ServiceController Class library not listed RRS feed

  • Question

  • I want to restart the server after writing to a table using ServiceController class, so that a datagridview will display the correct updated data. It requires the System ServiceProcess library.  ServiceProcess is not listed under System.  I'm using VS Community 2017.  Is there an alternative way of doing this?
    Saturday, April 15, 2017 11:55 AM

Answers

  • Apparently the ServiceController is not available in all Frameworks.  I change the Framework in Properties and it now available.  

    Thanks.

    Thursday, April 20, 2017 11:35 AM

All replies

  • Hi Richard,

    Welcome to the MSDN forum.

    Since our forum is to discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor, the ServiceController class belongs to .NET Framework Class Library, I will help you move this thread to the appropriate forum: .NET Framework>.NET Framework Class Libraries  to seek for a professional support, thank you for your understanding.     

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 17, 2017 2:48 AM
  • Hi RichardDunneBSc,

    >>Is there an alternative way of doing this?

    Please right click your project -> Properties -> Target framemwork -> select .Net Framework 4.6.1.

    Then right click Reference -> add reference -> search with "System.ServiceProcess ", Then you could find it.

    If it is a .Net Core Project. Please right click Dependencies -> Manage NuGet Packages..  -> search with key 'System.ServiceProcess' -> select 'System.ServiceProcess.ServiceControlle' -> install

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 17, 2017 7:44 AM
    Moderator
  • After updating a database and reading the updated info from the database, I can't figure out with a datagriview is not overwriting the data in the datagridvew straight away.  if I stop stop the process then start again, the new updated info is being displayed.  I thought stop and starting the server might resolve this.  This is my code:

    ServiceController sc = new ServiceController("SERVICENAME", "MACHINENAME");
                    if (sc.Status.Equals(ServiceControllerStatus.Running))
                        sc.Stop();
                        sc.Start();

    Ths is the exception its giving:

    System.InvalidOperationException: 'Cannot open Service Control Manager on computer 'MACHINENAME'. This operation might require other privileges.'

    I've checked the SQL Server(SQLEXPRESS) in Services and while Service Name is mentioned I didn't see any mention of Machine Name.  Am I looking in the wrong place?

     
    Tuesday, April 18, 2017 4:41 PM
  • Hi RichardDunneBSc,

    Based on your description, it seems that it is a new issue about the ServiceController, I would suggest that you could post a new thread. it will be beneficial to other communities who have the similar issue.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 20, 2017 7:47 AM
    Moderator
  • Apparently the ServiceController is not available in all Frameworks.  I change the Framework in Properties and it now available.  

    Thanks.

    Thursday, April 20, 2017 11:35 AM