在没有安装.NET的计算机上运行使用.NET Framework 4.7.2编写的C# Windows服务。

huangapple go评论73阅读模式
英文:

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

问题

我想知道我是否可以在没有安装.NET Framework的Windows计算机上启动一个使用.NET Framework 4.7.2编写的C# Windows服务?是否有办法运行这样的服务?

我在我的计算机上安装了这个服务,但是它已经安装了.NET Framework,并且我使用installutil.exe进行安装。但是,在没有.NET Framework的计算机上,安装过程会是什么样的呢?

英文:

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?

答案1

得分: 0

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

.NET框架的兼容版本可能预装在Windows上,具体取决于您使用的Windows版本。请参阅此表格以查看哪些版本在哪些Windows版本上预装。.Net 4.8 应该与 4.7.2 向后兼容,因此大多数最新版本的Windows 10 应该可以正常运行。

如果未安装.NET,Windows应该在首次运行应用程序时出现对话框,询问用户是否要安装.NET。但如果是Windows服务,则可能无法这样做,因为服务没有用户界面。我也在尝试在某些Windows版本上安装.NET框架时遇到了错误,但应该有可用的解决方法。

一个常见的解决方案是创建一个安装程序,如果需要的话,还会自动安装正确版本的.NET。

英文:

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.

huangapple
  • 本文由 发表于 2023年4月13日 19:02:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76004660.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定