Login

Recover Your Password

Return to Product Support > Learning Center > Developer References > Creating Add-ons > Create a DotNet C-sharp Windows Library Addon

Create a DotNet C-sharp Windows Library Addon

These instructions will walk you through the basic creation of an Add-on using Visual Studio .NET in C#.

  1. Install Contensive on your Development Machine. See Installation and Setup for details.
  2. Open Visual Studio and create a new C# Class Library project.
  3. Open project properties, click Application and set the default namespace to HelloWorldAddon.
  4. On the compile tab, click build events and paste this into Post-Build event (correcting paths as needed)

    copy $(TargetDir)"*.dll" "C:\Program Files\kma\Contensive\Addons"

  5. Add a reference to cpBase.dll -- usually found in c:\Program Files\kma\Contensive
  6. Paste the following code into the created class file.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Contensive.BaseClasses;

    namespace HelloWorldAddon
    {
    public class helloWorld : Contensive.BaseClasses.AddonBaseClass
    {
    //
    // execute method is the only public
    //
    public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
    {
    return "Hello World";
    }
    }
    }

  7. Build the DLL. 
  8. Go to your admin site and open the navigator to Navigator >> Manage Addons >> Advanced >> click on Add-ons
  9. Click Add to create a new addon. Set the following
    • Set the name to Hello World
    • Click the DLL tab and enter "Contensive.Addons.HelloWorldClass" in the Dot Net Class Full Name
    • Click the Placement tab and check the box "Place on Pages"
    • Click OK to save and close the record
  10. Go to the public site and turn on Quick Edit.
  11. Put the cursor anywhere in the wysiwyg editor and click the 'addons' drop-down menu. Select "Hello World" and a green addon will appear in your content.
  12. Click OK to close the editor and in it's place on the page will be "Hello World"
  13. To deploy the new addon on another server, see Deploying an Addon Collection