CosmosOS / Cosmos

Cosmos is an operating system "construction kit". Build your own OS using managed languages such as C#, VB.NET, and more!
https://www.goCosmos.org
BSD 3-Clause "New" or "Revised" License
2.93k stars 552 forks source link

Exception: System.Exception: Native code encountered, plug required. Check build output for more information. #3092

Open UnlegitDqrk opened 1 week ago

UnlegitDqrk commented 1 week ago

Expected Behaviour - What do you think that should happen?

It happend after restarting my PC before i got no problems, so i dont know where the Problem is

Actual Behaviour - What unexpectedly happens?

1>IL2CPU : error : Exception: System.Exception: Native code encountered, plug required. Check build output for more information.

Reproduction - How did you get this error to appear?

I dont know, i just restarted my laptop and sind then i get the exception

Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?

Dev Kit commit https://github.com/CosmosOS/Cosmos/pull/3087

Error Log: 1>IL2CPU : error : Exception: System.Exception: Native code encountered, plug required. Check build output for more information. 1> DO NOT REPORT THIS AS A BUG. 1> Please see http://www.gocosmos.org/docs/plugs/missing/ 1> Need plug for: System.Void System.Reflection.MetadataImport._GetCustomAttributeProps(System.IntPtr, System.Int32, &System.Int32, &System.Reflection.ConstArray)(Plug Signature: System_VoidSystem_Reflection_MetadataImportGetCustomAttributeProps_System_IntPtrSystemInt32System_Int32___System_ReflectionConstArray ). 1> Static: True 1> Assembly: System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e 1> Called from: 1>System.Reflection.MetadataImport::Void GetCustomAttributeProps(Int32, Int32 ByRef, System.Reflection.ConstArray ByRef) 1>System.Reflection.CustomAttribute::Boolean IsCustomAttributeDefined(System.Reflection.RuntimeModule, Int32, System.RuntimeType, Int32, Boolean) 1>System.Reflection.CustomAttribute::Boolean IsDefined(System.RuntimeType, System.RuntimeType, Boolean) 1>System.RuntimeType::Boolean IsDefined(System.Type, Boolean) 1>System.Reflection.MemberInfo::Boolean IsDefined(System.Type, Boolean) 1> 1> 1> at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug, String sourceItem) in C:\Users\finna\Desktop\Workspaces\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 562 1> at Cosmos.IL2CPU.ILScanner.ScanQueue() in C:\Users\finna\Desktop\Workspaces\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 751 1> at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod, IEnumerable`1 plugsAssemblies) in C:\Users\finna\Desktop\Workspaces\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 270 1> at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Users\finna\Desktop\Workspaces\CosmosOS\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 187 1>IL2CPU task took 00:00:04.8878459

ADev531 commented 1 week ago

Are you using Reflection? Otherwise, Can you give code?

UnlegitDqrk commented 1 week ago

Are you using Reflection? Otherwise, Can you give code?

No i imported CosmosTTF and the Cosmos-Optimization-Kit. But i didnt found anything with reflection

ADev531 commented 1 week ago

Are you using Custom Attributes? If not, can you provide the Kernel code?

UnlegitDqrk commented 1 week ago

Im using the ManifestResourceStream but here is the Kernel Code (not the cleanest): ` using Cosmos.Core.Memory; using Cosmos.HAL; using Cosmos.System; using Cosmos.System.ExtendedASCII; using Cosmos.System.Graphics; using Cosmos.System.Graphics.Fonts; using DarkOS.Apps; using DarkOS.Commands; using DarkOS.Main.Graphics; using DarkOS.Main.Hardware; using DarkOS.Main.User; using DarkOS.OptimizationKit; using DarkOS.Resources; using DarkOS.Utils; using System; using System.Collections.Generic; using System.Drawing; using System.Text; using Console = System.Console; using Sys = Cosmos.System;

namespace DarkOS.Main { public class Kernel : Sys.Kernel { public static readonly int screenHeight = 1920, screenWidth = 1080; public static readonly int DefaultFontHeight = 14;

    public static Canvas Canvas { get; private set; }
    public static Mode Mode { get; private set; }
    public static bool IsBooting { get; private set; } = true;
    public static bool Optimized = true;

    protected override void OnBoot()
    {
        IsBooting = true;
        base.OnBoot();

        Mode = new Mode((uint)screenHeight, (uint)screenWidth, ColorDepth.ColorDepth32);

        Canvas = FullScreenCanvas.GetFullScreenCanvas(Mode);
        Canvas.DrawImageAlpha(Images.Logo, (int)(Mode.Width / 2 - 258), (int)(Mode.Height / 5));
        Canvas.Display();

        PowerManager.DelayCode(500);
        KernelGraphics.DrawStatus($"Starting {Globals.NAME} {Globals.VERSION}");
        PowerManager.DelayCode(500);
        KernelGraphics.DrawStatus($"Developed by {Globals.AUTHOR} {Globals.COSMOS}");
        PowerManager.DelayCode(1500);
    }

    protected override void BeforeRun()
    {
        KernelGraphics.DrawStatus("Initializing Console");
        Console.SetWindowSize(90, 30);
        Console.OutputEncoding = CosmosEncodingProvider.Instance.GetEncoding(437);

        TTFManager.RegisterFont("KMB", Fonts.KodeMonoBoldByte);

        KernelGraphics.DrawStatus("Initializing File System");
        FileManagement.Initialize();
        PowerManager.DelayCode(2000);

        KernelGraphics.DrawStatus("Initializing Commands");
        CommandManager.Initialize();
        PowerManager.DelayCode(1000);

        KernelGraphics.DrawStatus("Initializing Entry Manager");
        EntryManager.Initialize();
        PowerManager.DelayCode(500);

        KernelGraphics.DrawStatus("Initializing User Control");
        UserControl.Initialize();
        PowerManager.DelayCode(500);

        KernelGraphics.DrawStatus("Initializing Graphics");
        DesktopGrid.gridItems.Add(new GridItem("Shell", Images.Control, 0, 0, 1));
        DesktopGrid.gridItems.Add(new GridItem("Welcome", Images.Control, 1, 0, 2));
        DesktopGrid.gridItems.Add(new GridItem("App 3", Images.Control, 0, 1, 0));
        Desktop.Initialize();
        PowerManager.DelayCode(500);

        IsBooting = false;
    }

    protected override void Run()
    {
        WriteMessage.Write($"{FileManagement.CurrentPath} >> ");
        string command = Console.ReadLine();
        CommandManager.RunCommand(command);

        try
        {
            Keyboard.KeyInfo = new ConsoleKeyInfo();
            Keyboard.IsKeyPressed = false;

            if (KeyboardManager.TryReadKey(out var key))
            {
                Keyboard.KeyInfo = new ConsoleKeyInfo(key.KeyChar, key.Key.ToConsoleKey(),
                    key.Modifiers == ConsoleModifiers.Shift,
                    key.Modifiers == ConsoleModifiers.Alt,
                    key.Modifiers == ConsoleModifiers.Control);

                Keyboard.IsKeyPressed = true;
            }

            Desktop.Update();
            CobaltCore.CallCore();
        }
        catch (Exception exception)
        {
            PowerManager.Panic(exception.Message);
        }
    }
}

} `

ADev531 commented 6 days ago

There is some problem (But not compile problem) in kernel file.

You should put that Canvas part to BeforeRun().

Anyways, I can't find any problems in this file. Can you give other files? (via comment or via github)