22

I am developing a game server in c#. Server talks to clients via sockets and sends byte[] using custom packet protocol. The question is, will this software be windows os specific or will be able to run on linux server. I've read different posts on different forums where developers say that their server is windows os only, some say it can run on linux.

Is there any specific factor? Does application have to be written specificly to be able to run on linux?

Scavs
  • 673
  • 1
  • 5
  • 16
  • 1
    Depends on if you run it on Mono or .NET Core. There are things that aren't implemented, but most is – Sami Kuhmonen Aug 28 '15 at 22:55
  • Assuming you've already searched for something like https://www.bing.com/search?q=c%23+run+on+linux it is not yet clear how your post is different from some existing questions on this topic. With more details the question may very well deserve no longer be duplicate. – Alexei Levenkov Aug 29 '15 at 00:58

1 Answers1

37

Update for 2020

.NET Core and .NET Framework are being merged together into ".NET 5". For all intents and purposes, this is just the next version of .NET Core (and .NET Framework is going away).

WPF still only runs on windows (though a universal XAML based UI system is in development), even though its running on .NET Core/5, and you still have to build specifically for Linux for supported project types, but the cross platform support is much better than when I originally wrote this.

Original

For .NET code to be able to run on Linux, you need a version of .NET that is compatible with that platform.

Full .NET is windows-only, but there is the Mono framework which runs on Linux. .NET Core is also being ported to linux.

Neither Mono or .NET Core supports the entirety of standard .NET. For example, neither will let you run a WPF application. So as long as your code is compatible with one of the aforementioned frameworks; yes, you can run it on Linux.

For your specific example, the classes you mention should be supported, and I don't think you'll have any trouble running under either Mono or .NET Core.

BradleyDotNET
  • 60,462
  • 10
  • 96
  • 117
  • 2
    Mono already supports nearly 99.9% of .net framework, usually any c# service or console application will work even if compiled against .net instead of targeting mono. – Gusman Aug 28 '15 at 23:15
  • 1
    @Gusman Thats true, the easiest example of what *doesn't* work is WPF (there are some .NET 4.5 classes that don't as well IIRC). – BradleyDotNET Aug 28 '15 at 23:16
  • 1
    Because that I said console or services :D, interface is just the lack as it's very OS specific. And yes, I love Mono XD – Gusman Aug 28 '15 at 23:17
  • If you come up on this answer, in the past 5 years this has changed dramatically! I suggest you research the differences between .NET Framework, .NET Core, and .NET Standard. – Philippe Haussmann Sep 26 '20 at 21:01
  • 1
    @PhilippeHaussmann I'm well aware of the differences. As you say the landscape has changed. I've written an update for future viewers of this answer. – BradleyDotNET Sep 28 '20 at 03:58
  • @PhilippeHaussmann and Bradley, can you tell me where this update is? – mLstudent33 Mar 28 '21 at 01:01
  • 2
    @mLstudent33 The update is right here. I edited this post when I made the comment – BradleyDotNET Mar 28 '21 at 03:31