Click here to Skip to main content
13,550,430 members
Click here to Skip to main content
Add your own
alternative version

Stats

9.4K views
9 bookmarked
Posted 23 Dec 2017
Licenced CPOL

Introduction to C# on ReactOS

, 31 Dec 2017
Rate this:
Please Sign up or sign in to vote.
How to compile and run the first C# application in ReactOS

Introduction

ReactOS is an open source alternative to the Windows operation system. Even if the first version of ReactOS dates back to 1998, there is still no 'stable' version of ReactOS. May be, the most important reason is a lack of attention.

I want to introduce how to compile and run a first very simple C# application at the current version 0.4.7.

I run ReactOS on ORACLE VM VirtualBox 5.1.26 and VMWare Workstation Player 12.5.8 and strictly recommend VirtualBox - ReactOS runs much more stable on VirtualBox.

Background

Unfortunately, the installations of .NET Framework 1.1 (even if it is an officially supported installation within the ReactOS 'Applications Manager') and .NET 2.0 SDK fail.

This prevents installing IDEs that are based on that (SharpDevelop 1.1 or 2.2, Visual Studio 2003 or 2005, ...).

Among the many attempts to install .NET Framework, two installations run through the complete setup procedure without any error message or warning:

  • .NET Framework 2.0 SP2 redistributable 32Bit (NetFx20SP2_x86.exe 24,416kB)
  • .NET Framework 4.0 redistributable 32Bit (dotNetFx40_Full_x86_x64.exe 49,268kB)

Although the installations are successful, the compilation of even the most simple C# application fails for both with 'fatal error CVT1103'.

But there is an escape from this limiting situation: MONO.

The ReactOS version 0.4.7 reports itself as 'Windows NT 5.2.3790 Service pack 2' (Windows Server 2003). The latest fully functional MONO version (a good download source is download.mono-project.com/archive), that can be installed for Windows NT version 5.2, is:

  • MONO 3.2.3 32Bit Windows installer (mono-3.2.3-gtksharp-2.12.11-win32-0.exe 100,854kB)

Newer MONO versions, that install successfully but are not fully functional, are e.g.:

  • MONO 3.12.1 32Bit Windows installer (mono-3.12.1-gtksharp-2.12.26-win32-0.msi 130,456kB)
  • MONO 4.3.2 32Bit Windows installer (mono-4.3.2.467-gtksharp-2.12.30.1-win32-0.msi 130,108kB)

The MONO versions newer than 3.2.3 contain a MONO runtime (mono.exe) that cannot be executed on ReactOS version 0.4.7. All these runtimes report the same error: ERROR_BAD_EXE_FORMAT - mono.exe is not a valid Win32 application.

Consequently, I recommend to install MONO 3.2.3. Since MONO 3.2.3 installs to C:\Program Files\Mono-3.2.3 and the MONO versions newer than 3.2.3 install to C:\Program Files\Mono, MONO 3.2.3, a newer version can also be installed in parallel. This provides the opportunity to test newer assemblies from case to case.

Even newer versions than MONO 4.3.2 require Vista (NT 6.0) at least.

Although all above mentioned setups run through the complete setup procedure without any error message or warning, they do not install Gtk# correctly. This becomes obviously, if a separate Gtk# installation is made. All gtk-sharp-2.12.xx.msi setups (a good download source is www.npackd.org/p/gtksharp) report the same error: The procedure entry point if_nametoindex could not be located in the dynamic link library IPHLPAPI.DLL. (Only the gtk-sharp-2.99.3.msi setup doesn't report this error, but it installs the Gtk# 3 preview.)

The incomplete installation of Gtk# 2.12.19 or higher prevents using MonoDevelop. Since none of the professional C# IDEs (SharpDevelop, Visual Studio, MonoDevelop) run on ReactOS 0.4.7, I fall back to Notepad++ (version 6.9 can be installed from the ReactOS Applications Manager). After a plug in Manager update, the NppExec plug in can be installed.

Using the Code

A very simple C# application shall be used to demonstrate the general operational capability.

using System;
using System.Reflection;

namespace ConsoleApp01
{
    public class ConsoleApp01
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("Hello from ReactOS on " + Environment.MachineName + "!");
            Console.WriteLine("OS Version: " + Environment.OSVersion);
            Console.WriteLine("Image runtime Version: " +
                              Assembly.GetExecutingAssembly().ImageRuntimeVersion.ToString());
            Console.WriteLine("Environment Version: " + Environment.Version.ToString());
            Console.WriteLine("Setup information: " + AppDomain.CurrentDomain.SetupInformation);
            Console.WriteLine("");
            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }
    }
}

As a first step, I recommend to check/extend the Path variable. It can be edited via Start | Settings | Control Panel | System | Advanced | Environment Variables and should include ";C:\Program Files\Mono-3.2.3\bin;C:\Program Files\GtkSharp\2.12\bin".

As a second step, I recommend to create a working folder C:\Documents and Settings\<user>\My Documents\.NET Apps, a project folder ConsoleApp01 and the source code file ConsoleApp01.cs.

Within the Notepad++, the [F6] key opens the command window, where new command scripts can be created and saved as well as command scripts started. The command script I use is:

NPP_SAVE
CD $(CURRENT_DIRECTORY)
C:\Program Files\Mono\lib\mono\4.5\mcs.exe "$(FILE_NAME)"

The resulting application executed with the mono runtime produces this output:

Hello from ReactOS on REACTOS-047!
OS Version: Microsoft Windows NT 5.2.3790.131072 Service Pack 2
Image runtime Version: v4.0.30319
Environment Version: 4.0.30319.17020
Setup information: System.AppDomainSetup

Press any key to continue...

The resulting application executed with the Microsoft .NET 4.0 runtime produces this output:

Hello from ReactOS on REACTOS-047!
OS Version: Microsoft Windows NT 5.2.3790 Service Pack 2
Image runtime Version: v4.0.30319
Environment Version: 4.0.30319.1
Setup information: System.AppDomainSetup

Press any key to continue...

Points of Interest

Although there are a lot of pitfalls, it is possible to compile and run .NET applications on ReactOS.

History

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Steffen Ploetz
CEO Ploetz + Zeller GmbH
Germany Germany
No Biography provided

You may also be interested in...

Comments and Discussions

 
QuestionReactOS in a VM... Pin
dandy7223-Dec-17 11:57
memberdandy7223-Dec-17 11:57 
AnswerRe: ReactOS in a VM... Pin
Steffen Ploetz30-Dec-17 3:29
professionalSteffen Ploetz30-Dec-17 3:29 
GeneralRe: ReactOS in a VM... Pin
dandy7231-Dec-17 3:46
memberdandy7231-Dec-17 3:46 
GeneralRe: ReactOS in a VM... Pin
Steffen Ploetz31-Dec-17 21:18
professionalSteffen Ploetz31-Dec-17 21:18 
GeneralRe: ReactOS in a VM... Pin
dandy721-Jan-18 3:59
memberdandy721-Jan-18 3:59 
GeneralRe: ReactOS in a VM... Pin
Steffen Ploetz4-Jan-18 1:47
professionalSteffen Ploetz4-Jan-18 1:47 
GeneralRe: ReactOS in a VM... Pin
dandy724-Jan-18 4:46
memberdandy724-Jan-18 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180515.1 | Last Updated 1 Jan 2018
Article Copyright 2017 by Steffen Ploetz
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid