# How to Write a Task Plugin for Cognex Designer

This topic describes how to write a Cognex Designer plugin, focusing on creating a Task block plugin.

Note: For detailed information on creating a Page element plugin, see the How to Write a Page Plugin for Cognex Designer topic.

To write a plugin for Cognex Designer, you will need the following tools:

- Microsoft Visual Studio 2012, 2013 or 2015

- Cognex Designer
- .NET 4.6

1. Open Visual Studio.

2. Create a new Project, and select Class Library.

3. Name your project and click OK.

4. In Solution Explorer, right-click on References and select Add Reference.... Add the following DLLs:

   - Cognex.Designer.Core
   - Cognex.Designer.Devices
   - Cognex.Designer.Scripting
   - Cognex.Designer.Sequences
   - Cognex.Designer.HMI (if you are creating an HMI control)

5. By default, these DLLs will be copied into the plugin folder during deployment. Trying to load the same system DLLs twice could cause runtime errors. It is recommended to set the Copy Local property for these DLLs to False.

   Note: When referencing a Cognex.Designer assembly in a Visual Studio project, the XAML designer may crash on 64-bit platforms when using Visual Studio 2012 with updates or later. Please see the Behavior Changes and Known Issues topic for more information.
6. Right-click on the project, select Properties.

7. In the Build tab, set the build output to: %ProgramData%\Cognex\Designer\Plugins. The recommended structure is the following: Plugin Folder \ {Company Name} \ {Plugin Name} \ { Version } \ { Architecture } \ Config file + DLLs. See an example below:

   Another alternative is to set the Output path to any arbitrary folder and use the /addPluginFolder=”{MyPluginsBinFolder} command line argument when starting Cognex Designer (see step 9 for more details).

8. In the Debug tab, select Start external program:%Installation Path%\Cognex.Designer.exe and the following command line argument: /project={pathToProjectFolder}

9. Two additional arguments:

   - /addPluginFolder={pathToPluginFolder} - Adds the folder to the search path when Designer discovers plugins.
   - /project={pathToProjectsFolder} - Loads the project in the given folder.

10. Set the working directory to the folder containing the Designer executable (by default: C:\Program Files\Cognex\Designer\<version>)
11. Save the project.

12. Create the plugin.config file for the plugin (simple XML file).

    Note: For more information about the plugin.config file, please see the Plugin Configuration topic.

13. In the plugin.config Properties, set the file to Copy if newer.

14. Add the plugin to your project as described in Plugin Configuration.