我正在尝试使用名为"mycommand“的命令创建一个附加组件。在使用VS 2019社区版构建它并将其放入add-on 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存储库中遵循以下命令模板:(Link)
发布于 2019-10-07 14:44:34
您的mycommand
类的名称不正确。要求它的名称与命令的名称完全相同,并添加" command“后缀。
要解决这个问题,只需将您的类重命名为MyCommandCommand
。
https://stackoverflow.com/questions/58264230
复制相似问题