是否有.NET OS抽象层使操作系统调用跨平台工作?

时间:2021-07-03 12:09:34

I really want to write .NET apps that run on any platform (PC, Linux and Mac). I am not really concerned about UI capabilities because these are mostly background services. I have heard of MONO and that it allows you to write .NET apps that run on Mac and Linux, but I want to be able to write a single app that when compiled for Windows will run as a Service, and when compiled for Linux will run as whatever the UNIX equivalent is. I also would like to be able to store things in the registry and have that work. Is there any way to write truly OS agnostic code like this? ...and DON'T say I should make it run on the web! :)

我真的想编写可在任何平台(PC,Linux和Mac)上运行的.NET应用程序。我并不真正关心UI功能,因为这些主要是后台服务。我听说过MONO并且它允许你编写在Mac和Linux上运行的.NET应用程序,但我希望能够编写一个应用程序,当为Windows编译时将作为服务运行,并且当编译为Linux时像UNIX等效的那样运行。我也希望能够将内容存储在注册表中并使其工作。有没有办法像这样编写真正的操作系统无关的代码? ......并且不要说我应该让它在网上运行! :)

2 个解决方案

#1


8  

Yes, Mono has the windows service stuff ported to Linux, but you are going to have to think of a better way to store configuration settings than Registry... Using XML files for instance would be cross platform.

是的,Mono将Windows服务移植到Linux上,但是您将不得不考虑一种比Registry更好的存储配置设置的方法......例如,使用XML文件将是跨平台的。

You should also check out mono's wiki on how to develop portable applications here.

你还应该看看mono的wiki如何在这里开发便携式应用程序。

#2


1  

Short answer: no. You could create an application which will run on both Windows and Linux. But there are platform-specific features and right now Mono could not automatically 'translate' those for you. A Windows Service is a good example of that.

简答:不。您可以创建一个可在Windows和Linux上运行的应用程序。但是有特定于平台的功能,现在Mono无法为您自动“翻译”这些功能。 Windows服务就是一个很好的例子。

#1


8  

Yes, Mono has the windows service stuff ported to Linux, but you are going to have to think of a better way to store configuration settings than Registry... Using XML files for instance would be cross platform.

是的,Mono将Windows服务移植到Linux上,但是您将不得不考虑一种比Registry更好的存储配置设置的方法......例如,使用XML文件将是跨平台的。

You should also check out mono's wiki on how to develop portable applications here.

你还应该看看mono的wiki如何在这里开发便携式应用程序。

#2


1  

Short answer: no. You could create an application which will run on both Windows and Linux. But there are platform-specific features and right now Mono could not automatically 'translate' those for you. A Windows Service is a good example of that.

简答:不。您可以创建一个可在Windows和Linux上运行的应用程序。但是有特定于平台的功能,现在Mono无法为您自动“翻译”这些功能。 Windows服务就是一个很好的例子。