-
Notifications
You must be signed in to change notification settings - Fork 103
Description
This 'Run' code in MW5.Plugins.TemplatePlugin.Tools.Vector.CustomVectorTool gives exception:
public override bool Run(ITaskHandle task)
{
Log.Info("Custom tool is running");
var numLyrs = _context.Map.Layers.Count;
Log.Info($"There are {numLyrs} layers on the map.");
return true;
}
The log/exception message at runtime is as below:
Custom tool is running
Error during tool execution: Custom tool from Template plugin
Exception: Stack trace:
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at MW5.Tools.Model.GisTask.<>c__DisplayClass43_0.<RunAsync>b__1(Task`1 task)
Inner exception: Object does not match target type.
Stack trace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at MapWinGIS._DMap.get_NumLayers()
at MW5.Plugins.TemplatePlugin.Tools.Vector.CustomVectorTool.Run(ITaskHandle task)
at MW5.Tools.Model.GisTask.Run(CancellationToken cancellationToken)
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
This code worked on my development machine (meaning all libraries are installed and ocx are registered etc), it fails on barebone testing machine (Windows 10). More specifically, I compiled the plugin on dev machine, then place it (the .dll file) under my installed MapWindow5\Plugins\ folder (also on dev machine) and it works, on our barebone testing machine (Windows 10), we also installed the same version of MapWindow5 (MapWindow-v5.6.3.0-x64.exe), but when I copied this same .dll onto our barebone testing machine's MapWindow5\Plugins\ folder, it gave above exception. Both dev machine and testing machine are Windows 10 at .Net framework 4.8.03752
I see the _context is protected, but the CustomVectorTool inherits from GisTool, so it should be accessible.