如何修复“ Expected Command postfix”错误?

时间:2019-10-07 06:05:46

标签: c# rpa g1ant

我正在尝试使用名为“ mycommand”的命令来创建附加组件。使用VS 2019 Community Edition构建它并将其放在加载项G1ANT.Robot / Add-on文件夹中后,它会导致G1ANT在启动时崩溃或显示如下错误消息:

Error Message

当G1ANT Studio崩溃时,日志文件中也存在相同的消息。

以下是插件的C#代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using G1ANT.Language;

// Please remember to refresh G1ANT.Language.dll in references

namespace G1ANT.Addon.MyAddon1
{
    [Addon(Name = "Addon", Tooltip = "...")]
    [Copyright(Author = "G1ANT LTD", Copyright = "G1ANT LTD", Email = "support@g1ant.com", Website = "www.g1ant.com")]
    [License(Type = "LGPL", ResourceName = "License.txt")]
    //[CommandGroup(Name = "", Tooltip = "")]
    public class Addon : Language.Addon
    {

        public override void Check()
        {
            base.Check();
            // Check integrity of your Addon
            // Throw exception if this Addon needs something that doesn't exists
        }

        public override void LoadDlls()
        {
            base.LoadDlls();
            // All dlls embeded in resources will be loaded automatically,
            // but you can load here some additional dlls:

            // Assembly.Load("...")
        }

        public override void Initialize()
        {
            base.Initialize();
            // Insert some code here to initialize Addon's objects
        }

        public override void Dispose()
        {
            base.Dispose();
            // Insert some code here which will dispose all unecessary objects when this Addon will be unloaded
        }

    }
    [Command(Name = "mycommand", Tooltip = "This is a test command")]
    public class mycommand : Command
    {
        public class Arguments : CommandArguments
        {
            // Enter all arguments you need
            [Argument(Required = true, Tooltip = "Enter some text here")]
            public TextStructure Text { get; set; }

            [Argument(Tooltip = "Result variable")]
            public VariableStructure Result { get; set; } = new VariableStructure("result");
        }

        public mycommand(AbstractScripter scripter) :base(scripter)
        {

        }

        // Implement this method
        public void Execute(Arguments arguments)
        {
            // Do something: for example, display argument text on the screen
            RobotMessageBox.Show(arguments.Text.Value);
            // Set result variable to the calculated text argument
            Scripter.Variables.SetVariableValue(arguments.Result.Value, new TextStructure(arguments.Text.Value));

            // If you need, set another variable to the calculated text argument
            Scripter.Variables.SetVariableValue("other", new TextStructure(arguments.Text.Value));
        }
    }

}

我正在遵循G1ANT.Sdk GitHub存储库中的以下Command模板:(Link

1 个答案:

答案 0 :(得分:2)

您的mycommand类名称错误。要求将其命名与命令名称完全相同,并添加“ Command”后缀。

要解决该问题,只需将您的班级重命名为MyCommandCommand