none
C# Windows Interactive Service return Environment.UserInteractive wrong value RRS feed

  • Question

  • Hello,

    After many unsuccessful searches, I post a message to find a solution to my problem. I have a C# Windows service that has been running for many, many years without any problems. This service is an interactive service that displays an HMI. However, in recent months, I have more and more problems under Windows 10 and Windows Server 2016 that refuses to launch the service interactively.

    When the service starts I get the following error message:

    Displaying a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

    I checked the value of the variable "Environment.UserInteractive" directly in C#, it returns "false".

    In addition, when I check the configuration of the Windows service the box "Allow the service to interact with the desktop" is checked.

    I do not understand where the problem comes from and especially where can I search?

    I am on a C # Framework .NET 4.6.1 application and under Visual Studio 2015.

    Thank you in advance for your assistance !

    Tuesday, June 11, 2019 2:08 PM

All replies

  • Hi Hesion78,

    Thank you for posting here.

    >>I have more and more problems under Windows 10 and Windows Server 2016 that refuses to launch the service interactively.

    I want to know if you update the windows, which may change UserInteractive's value.

    Based on my search, the following link may be helpful for you.

    https://stackoverflow.com/questions/8928713/how-to-resolve-error-showing-a-modal-dialog-box-or-form-when-the-application-i

    Best Regards,

    Jack


    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.

    Wednesday, June 12, 2019 5:39 AM
    Moderator
  • I have more and more problems under Windows 10 and Windows Server 2016 that refuses to launch the service interactively.

    https://www.coretechnologies.com/blog/windows-services/interactive-services-removed-windows-10/

    https://docs.microsoft.com/en-us/windows/desktop/services/interactive-services

    <copied>

    Services cannot directly interact with a user as of Windows Vista. Therefore, the techniques mentioned in the section titled Using an Interactive Service should not be used in new code.

    <end>

    I would say that if it's removed from the workstation O/S, then it is removed from the server version of the O/S too.



    • Edited by DA924x Wednesday, June 12, 2019 5:56 AM
    Wednesday, June 12, 2019 5:41 AM