3
namespace CosmosKernel2
{
    public class Kernel : Sys.Kernel
    {
        protected override void BeforeRun()
        {
           Console.WriteLine("hi.");
        }
        protected override void Run()
        {
            Console.WriteLine("Input:");
            String input = Console.ReadLine();
        if (input.StartsWith("echo"))
            {
               var index = input.LastIndexOf(input);  // ERROR HERE
               Console.WriteLine("echo: " + input.Substring(cmdLastIndex));
            }}}}

I am making a simple OS to echo user's input. However, I am getting some errors. I see nothing wrong with creating a var index and storing the last index.

Here is my error:

 Build started: Project: CosmosKernel2Boot, Configuration: Debug x86 ------
1>  Invoking il2cpu.exe "DebugEnabled:True" "StackCorruptionDetectionEnabled:False" "DebugMode:Source" "TraceAssemblies:" "DebugCom:1" "UseNAsm:True" "OutputFilename:C:\Users\Lindsay\Documents\Visual Studio 2015\Projects\CosmosKernel2\CosmosKernel2\bin\Debug\CosmosKernel2Boot.asm" "EnableLogging:True" "EmitDebugSymbols:True" "IgnoreDebugStubAttribute:False" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.Core.Plugs.dll" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.Debug.Kernel.Plugs.dll" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.System.Plugs.dll" "References:C:\Users\Lindsay\Documents\Visual Studio 2015\Projects\CosmosKernel2\CosmosKernel2\bin\Debug\CosmosKernel2.dll" "References:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" 
1>C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets(31,5): error : Error occurred while invoking IL2CPU.
1>  Executing command line "C:\Users\Lindsay\Downloads\Cosmos User Kit\Build\IL2CPU\IL2CPU.exe" "DebugEnabled:True" "StackCorruptionDetectionEnabled:False" "DebugMode:Source" "TraceAssemblies:" "DebugCom:1" "UseNAsm:True" "OutputFilename:C:\Users\Lindsay\Documents\Visual Studio 2015\Projects\CosmosKernel2\CosmosKernel2\bin\Debug\CosmosKernel2Boot.asm" "EnableLogging:True" "EmitDebugSymbols:True" "IgnoreDebugStubAttribute:False" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.Core.Plugs.dll" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.Debug.Kernel.Plugs.dll" "References:C:\Users\Lindsay\Downloads\Cosmos User Kit\Kernel\Cosmos.System.Plugs.dll" "References:C:\Users\Lindsay\Documents\Visual Studio 2015\Projects\CosmosKernel2\CosmosKernel2\bin\Debug\CosmosKernel2.dll" "References:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll" 
1>  Working directory = 'C:\Users\Lindsay\Documents\Visual Studio 2015\Projects\CosmosKernel2\CosmosKernel2\bin\Debug\'
Erik Philips
  • 53,428
  • 11
  • 128
  • 150
m.k
  • 73
  • 1
  • 10
  • 1
    That doesn't look like an error. That looks like typical build information. – Carcigenicate Oct 25 '16 at 21:43
  • Then what is the problem? It's not letting me run VMware with the code above – m.k Oct 25 '16 at 21:45
  • How do you know that "1>C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets(31,5): error : Error occurred while invoking IL2CPU." is due to the `var index = input.LastIndexOf(input);` line? Also, `aString.LastIndexOf(aString)` should always return 0 no matter what. – Quantic Oct 25 '16 at 21:45
  • Oops, there is an error in there. Hard to read long text in the app. It looks like it's unrelated to your code directly though. – Carcigenicate Oct 25 '16 at 21:47
  • "I fixed it by restarting the project": https://github.com/CosmosOS/Cosmos/issues/221 (at the bottom). – Carcigenicate Oct 25 '16 at 21:48
  • @Carcigenicate I fixed it by restarting my computer. It's weird, but it works! – m.k Oct 26 '16 at 02:21
  • 1
    @m.k There you go. Not to sound mean, but I googled the error and had an answer within 30 seconds. Whenever you get an error that you can't solve on your own, Google it! 9/10 someone else has had the problem and at the very least will be able to get you closer to solving it. – Carcigenicate Oct 26 '16 at 10:46

1 Answers1

0

Looks like you're referring to the undefined variable cmdLastIndex. You should rename it to index.

Console.WriteLine("echo: " + input.Substring(cmdLastIndex));
kristianp
  • 5,496
  • 37
  • 56