C# “宇宙”;“你好,世界”;插件生成错误
我刚刚安装了Cosmos,并尝试运行默认设置的测试程序。这就是代码:C# “宇宙”;“你好,世界”;插件生成错误,c#,visual-studio-2010,cosmos,C#,Visual Studio 2010,Cosmos,我刚刚安装了Cosmos,并尝试运行默认设置的测试程序。这就是代码: using System; using System.Collections.Generic; using System.Text; using Sys = Cosmos.System; namespace CosmosKernel2 { public class Kernel : Sys.Kernel { protected override void BeforeRun()
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);
}
}
}
当我试图编译它时,它说:
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
我正在使用Visual Studio 2010,我已安装此处列出的所有要求:
提前谢谢你 “plug needed”错误意味着您使用了依赖于内部调用或PInvoke的某些方法,因此Cosmos无法编译它
您可能使用的方法尚未插入,或者可能缺少对该实现的引用(这使Cosmos认为它未实现)
使用以下指南帮助您入门:
更新:尝试使用类似以下代码的内容:
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!");
}
}
}
似乎Cosmos在windows 8/8.1上运行得不太好。因此,唯一的解决方案是安装Windows 7或运行安装了Windows 7的虚拟机(后者对我有效)我已经安装了PInvoke,但问题仍然存在。我能做些什么来修复它?看看这段youtube视频:,尝试使用类似视频中的代码。我对C#还是很陌生,但问题是我需要Cosmos在学校做一个项目。安装VS2008有效吗?我对版本没有任何偏好&等等,只是一个可以由VM引导的工作代码。此外,没有安装Cosmos.Compiler包(它会导致错误),您可以使用任何visual studio版本。只需复制粘贴我在答案中添加的代码。使用您想要的任何文本添加Console.WriteLine命令,该命令应该适用于您。我添加了,但存在以下错误:命名空间“Cosmos”中不存在类型或命名空间名称“Compiler”(是否缺少程序集引用?);另一个:系统找不到指定的文件。(来自HRESULT:0x80070002的异常)System.Reflection.RuntimeAssembly.nLoadFile。。。我从这里下载了推荐的下载:注意console.readline()总是返回一个字符串,因此将其设置为var是低效的。