1

I've just installed Cosmos and tried to run the test program given by default. That's the code:

using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;

namespace CosmosKernel2
{
    public class Kernel : Sys.Kernel
    {
        protected override void BeforeRun()
        {
            Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
        }

        protected override void Run()
        {
            Console.Write("Input: ");
            var input = Console.ReadLine();
            Console.Write("Text typed: ");
            Console.WriteLine(input);
        }
    }
}

When I try to compile it, it says:

Error   8   Plug needed. System.Void  System.Threading.Monitor.Exit(System.Object)
   at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 663
   at Cosmos.IL2CPU.ILScanner.ScanQueue() in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 779
   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 284
   at Cosmos.Build.MSBuild.IL2CPUTask.Execute() in c:\Data\Sources\Cosmos\source2\Build\Cosmos.Build.MSBuild\IL2CPUTask.cs:line 239 C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets    32  10  CosmosKernel2Boot

I'm using Visual Studio 2010, I have installed all requirements listed here: http://cosmos.codeplex.com/releases/view/123476

Thank you in advance!

Hossein Narimani Rad
  • 31,361
  • 18
  • 86
  • 116
Ivo Valchev
  • 215
  • 3
  • 11
  • note that a console.readline() always returns a string, therefor making it a var is inefficient. – Thealon Apr 23 '15 at 08:41

2 Answers2

1

"plug needed" error means that you have used some method which relies on an internal call or PInvoke, and thus Cosmos cannot compile it.

You probably use a method that has not been plugged yet or maybe missing a reference to that implementation (which makes Cosmos think it is not implemented)

Use the below guides to help you getting started:

http://www.codeproject.com/Articles/220076/Csharp-Open-Source-Managed-Operating-System-Intro

http://www.codeproject.com/Articles/29523/Cosmos-C-Open-Source-Managed-Operating-System

Update: Try using something similar to this code:

using System;
using Cosmos.Compiler.Builder;

namespace CosmosBoot1
{
    class Program
    {
        #region Cosmos Builder logic
        // Most users wont touch this. This will call the Cosmos Build tool
        [STAThread]
        static void Main(string[] args)
        {
            BuildUI.Run();
        }
        #endregion

        // Main entry point of the kernel
        public static void Init()
        {
            var xBoot = new Cosmos.Sys.Boot();
            xBoot.Execute();
            //There's supposed to be a bit of text here. Change it to Console.WriteLine("Hello world!");
        }
    }
}
DeJaVo
  • 3,091
  • 2
  • 17
  • 32
  • I've installed PInvoke, but the problem is still there. What can I do to fix it? – Ivo Valchev Apr 23 '15 at 08:22
  • See this youtube video: https://www.youtube.com/watch?v=V8_rCIvzq4I , try using something similar to the code in the video. – DeJaVo Apr 23 '15 at 08:34
  • I'm still quite new to C#, but the thing is that I need Cosmos for a project in school. Would installing VS 2008 work? I have no preference at all about versions & etc, just a working code that can be booted by a VM. Also, there is no Cosmos.Compiler package installed (it causes an error) – Ivo Valchev Apr 23 '15 at 08:58
  • you can use any visual studio version. just copy paste the code I added in my answer. add Console.WriteLine command with whatever text you would like and it should work for you. – DeJaVo Apr 23 '15 at 09:03
  • I did and there are the following errors: The type or namespace name 'Compiler' does not exist in the namespace 'Cosmos' (are you missing an assembly reference?); And the other other one: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) System.Reflection.RuntimeAssembly.nLoadFile... I downloaded the recommended download from here: http://cosmos.codeplex.com/releases/view/58275 – Ivo Valchev Apr 23 '15 at 09:18
  • I think you need to start from the beginning than.... here is a recomended guide for Basic Cosmos and C# : https://docs.google.com/document/d/1S2neqs6GLWM1oOl1IbFiLRQMVvIzgsLgsd7_5PnBPFE/edit – DeJaVo Apr 23 '15 at 09:35
  • Thanks for all you time! :) But actually this tutorial (which is great and I'm going to use) assumes that I've successfully installed everything needed and that I can run a simple hello world program, but sadly it's not the case-I wrote some code without errors. Here: using System; using System.Collections.Generic; using System.Text; using Sys = Cosmos.System; namespace CosmosKernel5 { class Program { public static void Init() { var xBoot = new Cosmos.System.Console(); xBoot.WriteLine("True"); while (true) ; } } } – Ivo Valchev Apr 23 '15 at 09:44
  • But when I run it, a window pops up saying Assertion failed and that my file.cpdb is missing. How could I fix it? Also in order to compile without any errors, I set it to 32-bit (x86). Thank you! – Ivo Valchev Apr 23 '15 at 09:45
  • It means the pdb linked to cpdb is missing. try to change CPU architecture to any CPU or x64. – DeJaVo Apr 23 '15 at 09:52
  • When I try to compile under x64 it says that the namespace Cosmos is missing. – Ivo Valchev Apr 24 '15 at 05:01
0

It seems that Cosmos isn't working well with windows 8/8.1. So the only solution is to either install Windows 7 or run a virtual machine with installed Windows 7 (the latter worked for me)

Ivo Valchev
  • 215
  • 3
  • 11