Search code examples
c#.netwindowswindows-services

Running windows service writen in C# on .NET framework 4.7.2 on computer without installed .NET


I'm wondering if I can start a Windows service written in C# on .NET Framework 4.7.2 on a Windows computer that doesn't have .NET Framework installed? Is there any way to run such a service?

I installed the service on my computer, but it has .NET Framework installed, and I used installutil.exe for installation. However, what would the installation process look like on a computer without .NET Framework?


Solution

  • No, you cannot run any .net program without a compatible version of .net installed, unless you use a .net core self contained application.

    A compatible version of .Net framework may be preinstalled on windows, depending on what windows version you are running. See this table to check what versions are preinstalled on what versiosn. .Net 4.8 should be backwards compatible with 4.7.2, so most recent versions of windows 10 should be fine.

    If .Net is not installed, windows should present a dialog asking the user if he/she wants to install .Net the first time the application is launched. But if it is a windows service this may not be possible, since services lack an UI. I have also encountered errors when trying to install .net framework on some versions of windows, but there should be workarounds available.

    A common solution is to create a installer that also installs the correct version of .net automatically if needed.