Login

Recover Your Password

Return to Product Support > Learning Center > Developer References > Developer Tutorials > Integrating a Visual Studio Assembly into an Addon

Integrating a Visual Studio Assembly into an Addon

This tutorial demonstrates how to integrate a Visual Studio windows library assembly into a Contensive Addon. The Addon Collection used in this tutorial is the one created in the earlier tutorial.

Download and Install the Contensive Addon Visual Studio Project and Item Template

  1. Get the Visual Studio Template Project from GitHub or Download a zip file here.

  2. Open the appropriate project, Visual Basic or c sharp.

  3. Create a Project Template.

    Click File > Export Template

    Select Project Template and click Next

    On the template options page, change the Template Name to "Contensive Addon Collection" and click Finish.

    Use this new template when starting a new addon collection project.

  4. Create an Item Template

    Click File > Export Template

    Select Item Template and click Next

    Select the addonClass and click next.

    Do not add any item references and click next

    Click Finish to create an item template. Use this template when adding a new addon class to a project.

Create a new Visual Studio Project that you can call from a Contensive Addon

  1. Open Visual Studio and create a new project. In the New Project dialog, select the Contensive Addon Collection template. This is the template you created in the first section of this tutorial. Set the project and solution names and select the location to save your project. Click OK.

  2. When the project is finished building, open the project properties and configure as follows:

    In the Application tab, set the assembly name similar to the project's name. In this example I will use SampleCollection. For visual basic, set the Root Namespace to empty. For c-sharp, you can ignore the default namespace.

    Set the Build Events. For c-sharp they are in the Build Events tab. For visual basic, click the Build Events button in the Compile tab. There are two copy commands in the Post Build section. You only need the one that applies to your machine. If you have a 64-bit machine, delete the line with "Program Files". If you have a 32-bit machine, delete the one with "Program Files (x86)". If you leave them both, it still works, you will just see a copy error for one of them after each build.

    Under references, add the Contensive API object, cpBase.dll found typically found in Project Files (x86)\kma\Contensive

  3. The class created with the project, named addonClass by default will contain your addon executable code. Configure the class as follows.

    Open the addonClass and set the namespace to represent your collection. In this case I will use SampleCollection.

    Change the public class name to represent the addon functionality. In this case I will use helloWorldClass.

    The only method in the class is Execute(). It simply returns the string "Visual Studio Contensive Addon - OK Response"

  4. Build the project.

Call your Visual Studio assembly from a Contensive Addon

  1. Go to your Contensive development site and open the admin page (/admin). If the sample collection from the earlier tutorial is not in your site, go to the earlier tutorial and create it.

  2. Edit the addon in the collection. Click the DLL Tab and enter the Dot Net Class Full Name as collectionName.className. In this case I entered SampleCollection.helloWorldClass. Save.

  3. Run the addon from the Navigator on the left by opening Navigator >> Manage Addons >> Sample Collection >> click on Sample Addon

  4. When the addon runs, the screen includes the returned message from your Visual Studio class, "Visual Studio Contensive Addon - OK Response"