Click here to Skip to main content
13,703,000 members
Click here to Skip to main content
Add your own
alternative version

Stats

14.2K views
18 bookmarked
Posted 23 Dec 2017
Licenced CPOL

Introduction to C# on ReactOS

, 11 Jul 2018
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.


Update July-2018: The version 0.4.8 is out since May 2018 and will be discussed here as well.


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.


Update July-2018: I use ORACLE VM VirtualBox 5.2.12 for ReactOS version 0.4.8.


The virtual machine has been created with 2048 MByte RAM and 25 GByte HDD. The default network adapter "Intel PRO/1000 MT Desktop (8254OEM)" must be changed to "PC-net PCI II (Am79C970A)" in order to work properly.

The first installation I do is Firefox 45.0.1 or 48.0.2 (can be installed from the ReactOS Applications Manager). Immediately after installation, I open [≡]|[Options] and switch [Search]|[Search Engine] to "DuckDuckGo" (my personal affinity to search without supervision and get results not ordered by the preference of the search machine provider) as well as [Advanced]|[Update] "Automatically ..." to "Never ..." (because newer Firefox versions, e.g. 52.0.1esr, will not start on ReactOS).

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.


Update July-2018: There is an additional message on ReactOS version 0.4.8 during .NET Framework 1.1 installation:

There is also an additional message on ReactOS version 0.4.8 during .NET Framework 2.0 installation:


This prevents installing IDEs that are based on .NET 1.1 or 2.0 (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' (for source code, see section Using the Code at the bottom of the article).

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

The ReactOS versions 0.4.7 and 0.4.8 reports themselves as 'ReactOS [Version 5.2.3790] Service pack 2' (which is equivalent to Windows Server 2003).

The latest fully functional MONO version (a good download source is download.mono-project.com/archive), that can be installed for ReactOS version 0.4.7, is:

  • MONO 3.2.3 32Bit Windows installer (mono-3.2.3-gtksharp-2.12.11-win32-0.exe 100,854kB)
    This installation reports: Mono JIT compiler version 3.3.0 (which is from 2012)

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 and a newer version can be installed in parallel as well. This provides the opportunity to test newer assemblies from case to case.


Update July-2018: On ReactOS version 0.4.8 fully functional MONO version, I've tested, are:

  • MONO 3.2.3 32Bit Windows installer (mono-3.2.3-gtksharp-2.12.11-win32-0.exe 100,854kB)
    This installation reports: Mono JIT compiler version 3.3.0 (which is from 2012)
  • MONO 3.12.1 32Bit Windows installer (mono-3.12.1-gtksharp-2.12.26-win32-0.msi 130,456kB)
    This installation reports: Mono JIT compiler version 3.12.1 (which is from 2014)
  • MONO 4.0.1 32Bit Windows installer (mono-4.0.1-gtksharp-2.12.26-win32-0.msi 118,800kB)
    This installation reports: Mono JIT compiler version 4.0.1 (which is from 2014)
  • MONO 4.0.2 32Bit Windows installer (mono-4.0.2-gtksharp-2.12.26-win32-0.msi 118,820kB)
    This installation reports: Mono JIT compiler version 4.0.2 (which is from 2014)
  • MONO 4.0.3 32Bit Windows installer (mono-4.0.3-gtksharp-2.12.26-win32-0.msi 117,720kB)
    This installation reports: Mono JIT compiler version 4.0.3 (which is from 2014)

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

  • MONO 4.2.1 32Bit Windows installer (mono-4.2.1.124-gtksharp-2.12.30-win32-0.msi 121,564kB)
  • 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 4.0.3 contain a MONO runtime (mono.exe) that cannot be executed on ReactOS version 0.4.8. The MONO versions 4.2.1 and 4.3.2 report the same error: The procedure entry point InitializeConditionVariable could not be located in the dynamic link library KERNEL32.dll.

Consequently, I recommend to install MONO 4.0.3. It installs to C:\Program Files\Mono.


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

Although all mentioned setups up to MONO 4.0.3 run through the complete setup procedure without any error message or warning, they do not install Gtk# correctly.

This becomes obvious, 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, that currently provides gtk-sharp versions 2.12.20 to 2.12.45) 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.9 or higher (required for MonoDevelop-2.8.6.5.msi) prevents using MonoDevelop. Since none of the professional C# IDEs (SharpDevelop, Visual Studio, MonoDevelop) run on ReactOS 0.4.7 and 0.4.8, I fall back to Notepad++ (version 6.9 can be installed from the ReactOS Applications Manager). After a plug in Manager update, the NppExec plugin 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" for MONO 3.2.3 or ";C:\Program Files\Mono\bin;C:\Program Files\GtkSharp\2.12\bin" for MONO 3.12.1 or higher.

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 and restrictions, 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 - max resolution too low, not even HD Pin
MahBulgariaRebrn11-Jul-18 11:50
memberMahBulgariaRebrn11-Jul-18 11:50 
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 | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180920.1 | Last Updated 11 Jul 2018
Article Copyright 2017 by Steffen Ploetz
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid