首页 > 解决方案 > Cosmos 基本示例无法运行

问题描述

我正在尝试使用 C# 开始使用 Cosmos。我安装了 Visual Studio 2017 和 Cosmos 用户工具包。在 youtube 上的许多教程中,我看到 VMWare 播放器在按下“运行”按钮时就会启动。

但是,就我而言,我收到以下错误:“无法直接启动具有输出类型的类库的项目。”

错误截图

我的代码真的很简单,是文档中给出的基本示例。请帮我解决这个问题。

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);
        }
    }
}

标签: c#visual-studiooperating-systemcosmos

解决方案


Cosmos 是一个内核。您不能“在 Windows 上运行内核”。如果你想直接从 Visual Studio 运行你的 cosmos 内核,你需要一个虚拟机。

Cosmos 使用开箱即用的 Vmware。确保已安装它。或者你可以使用 VirtualBox,我个人也让它在上面运行。

您还可以在带有引导加载程序的实际机器上运行它,例如 Grub。您可以通过这种方式双重引导到 Windows 或您自己的内核。

Cosmos 在这里有说明:https ://github.com/CosmosOS/Cosmos/wiki/Deployment

将 cosmos 生成的 boot 设置为启动项目来运行它。


推荐阅读