Award
Congratulations DJ Sures, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

I Am Trying To Connect My Bot In An Ezb Plugin

Assistance Requested

Help Jlucben with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

Jlucben claims to have checked these sources:
 
#1

Hello

I'm a french new user and trying to connect my bot which is based on Synbot and SIML Package in an EZB plugin

I'm using Nugget to include the Syn Package in my solution.

The plugin is working fine without reference to Syn.
With a Windows forms appplication (Not a plugin) , bot and reference to Syn are working fine.

But when I include reference to Syn Package in the plugin , I get an error :


User-inserted image

Thanks for your help

Here is my code for plugin

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using Syn.Bot;

namespace plugin_SIML
{
public partial class Mainform : EZ_Builder.UCForms.FormPluginMaster
{
public Mainform()
{
InitializeComponent();
Console.SetOut(new ControlWriter(Textconsole));
}
///
/// This method is called by EZ-Builder when it requests the configuration for your plugin.
/// EZ-Builder will request the configuration when the control is created and when the project is saved.
/// The data set in this configuration will be serialized and saved in the EZ-Builder user's project.
/// Custom data may be stored in the STORAGE dictionary.
///
public override EZ_Builder.Config.Sub.PluginV1 GetConfiguration()
{

return base.GetConfiguration();
}

///
/// This method is called by EZ-Builder when a project is loaded or when the control is added to a project.
/// Set your default data in here!
/// The configuration from the user's project file will be set using this method.
/// *Note: The plugin must call Base.SetConfiguration(cf) in your override. See the example!
/// Also note that this is a good place to ensure all required configuration data exists.
/// In the case of a newer version of your plugin where different configuration data may be required outside of the users configuration file, set it here.
///
public override void SetConfiguration(EZ_Builder.Config.Sub.PluginV1 cf)
{

base.SetConfiguration(cf);
}

///
/// This method is called by EZ-Builder when another control sends a command to this control using the EZ-Script ControlCommand() function.
/// The available ControlCommand() functions for this control should be returned in the GetSupportedControlCommandsMethodsForSlave() override.
///
public override void SendCommand(string windowCommand, params string[] values)
{

base.SendCommand(windowCommand, values);
}

///
/// This method is called by EZ-Builder for the Cheat Sheet to receive all available ControlCommand() syntax for this control.
/// When the ControlCommand() is called for this function, see the SendCommand() override.
///
public override object[] GetSupportedControlCommands()
{

return base.GetSupportedControlCommands();
}

private void button1_Click(object sender, EventArgs e)
{
Console.WriteLine("Test Create Bot");
var simlBot = new Syn.Bot.Siml.SimlBot();
}

private void button2_Click(object sender, EventArgs e)
{
Console.WriteLine("Stop");
}

private void Textconsole_TextChanged(object sender, EventArgs e)
{

}
}
public class ControlWriter : TextWriter
{
private Control textbox;
public ControlWriter(Control textbox)
{
this.textbox = textbox;
}

public override void Write(char value)
{
textbox.Text += value;
}

public override void Write(string value)
{
textbox.Text += value;
}

public override Encoding Encoding
{
get { return Encoding.ASCII; }
}
}
}

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

As the error says, the DLL is not in the plugin folder. You can't use a DLL that cannot be physically located. Have your project copy the DLL to the plugin folder.

The error reads that the DLL must be copied to the plugin folder. Right click on your DLL in the project reference and select it to be copied with build. This is the same as you have had to do with the plugin.xml.

There's information on this topic in the plugin tutorial: http://www.ez-robot.com/Tutorials/UserTutorials/146/20


Also, as preemptive advice for performance, I notice the ControlWriter is += to a textbox instead of Appending. And that's an incredibly slow and memory hungry way to append information to a text box. I would recommend using an ezbuilder Invoker as per the compliance here: http://www.ez-robot.com/Tutorials/UserTutorials/146/21

Using the Invoker would ensure the appended text is performed on the correct thread and not using valuable GUI thread CPU time. It also uses much less memory by not += memory copying the contents for appending.

Lastly, please is the [ code ] and [ /code ] formatting when pasting code so it can be readable.

#3

Many thanks DJ

But as you can see below the DLL is copied in the plugin Folder

Thanks for your help
User-inserted image

#4

It's very strange - the syn DLL is looking for system.dll in the plugin folder.

I cannot seem to reproduce the issue on my machine. I will run a few more tests and get back to you.

#5

Thanks DJ

In a normal Windows Form Application , all is working fine.
Ask me if you need more détails on my configuration

#6

I'm still looking into this

#7

I'm struggling to understand why JINT.DLL is programmatically requesting to load the System.dll assembly... that's what is causing the message, however i cannot seem to track down why or how it is happening.

#8

@DJ,

I had the same problem sometime ago:
EZ-Builder + plugin + Component

After struggling for a few days, i moved the code to an external App to keep going.
Later i developed a plugin framework to test the dynamic load like you do in EZ-Builder and i couldn't reproduce the problem.
So far only happens with EZ-Builder.

My solution to help troubleshooting:

AssemblyLoadTest.zip

1) plugin
your smtp client (I added a button to do the test)

2) Component
Simple class with a Regex method.
Note: i had problems with another class but i can't remember.

User-inserted image

#9

It appears to be an issue when loading portable libraries. I added a second library that is loaded to your example, which works. Try this: AssemblyLoadTest-NoCrash.zip

#10

Yes it works.

Unfortunately PCL assemblies are becoming more frequent, some of them don't offer a non PCL version.

DJ did you tried the plugin+PCL issue in debug Mode (EZ-Builder code open in the visual studio) ?

If you want to dig the issue, you can try to call the plugin early as possible in your EZ-Builder code to confirm if the problem surfaces immediately or after loading other assemblies.