0

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

错误信息

当 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 存储库中的这个命令模板:(链接

4

1 回答 1

2

您的mycommand班级名称不正确。要求是将其命名为与命令名称完全相同并添加“命令”后缀。

要解决此问题,只需将您的类重命名为MyCommandCommand.

于 2019-10-07T14:44:33.977 回答