Debugging a custom Coveo conversion script

This post details the way I figured out how to debug a Coveo Pre or Post Converter written in .NET.
This blog post comes off the back of a question I asked on the Coveo Answers website. https://answers.coveo.com/questions/3548/how-do-you-debug-a-net-c-conversion-script
Disclaimer: I am just starting to learn the inner workings of Coveo, and I could not find any documentation on exactly how to do this. If anyone has any other way of debugging, please let me know in the comments, but hopefully this can help anyone who was running into the same issues that I did.

Firstly, I am running Coveo Enterprise Search 7. This may change in future versions of CES, so be aware that this is how I managed to get it to work at the time of writing this post.

Setting up the project

  • Set up a C# class library project in Visual Studio.
  • Change the Target Framework of the project to .NET Framework 3.5.
    • Right click on the project
    • Select Properties
    • On the Application tab, select .NET Framework 3.5 from the Target Framework drop down.
  • Add a class for your conversion script. An example of one is below.
    using System;
    using Coveo.CES.ConversionScriptLoader;
    using Coveo.CES.ConversionScriptLoader.Interops.x64;
     
    namespace SampleCustomConverter {
        public class MySamplePostConverter : CustomConverter {
            public override void RunPostConverter(IPostConversion p_PostConversion, IDocumentInfo p_DocumentInfo) {
                p_PostConversion.Trace("Hello from my .NET post converter: " + p_DocumentInfo.URI, SeverityEnumeration.SeverityNormal);
            }
        }
    }
  • Build the project in a Debug configuration.

Setting up the conversion script

When you go to add a post conversion script you are required to enter the Script File path and the Type Name.

  • In the Script File field, enter the full path of the DLL produced by the project.
    • i.e C:\MyProjects\SampleCustomConverter\bin\Debug\SampleCustomConverter.dll
  • In the Type Name field, enter the fully qualified type name of your class.
    • In [namespace].[class name] format
    • i.e SampleCustomConverter.MySamplePostConverter
  • Save the conversion script and apply it as you normally would.

Attaching the debugger

Back in Visual Studio, attach the debugger to the CESConverter7.exe process.

  • Select Debug -> Attach to Process
  • Change to ‘Managed (v3.5, v3.0, v2.0) code’
    • In the ‘Attach To:’ field, click ‘Select’
    • Select ‘Debug these code types’
    • Ensure you have ‘Managed (v3.5, v3.0, v2.0) code’ checked
  • Select the CESConverter7.exe process.
    • If the process doesn’t show up, you may have to start and stop a rebuild of the indexes in the CES Admin Tool.
  • Click ‘Attach’

Rebuild the source in the CES Admin Tool where you’ve setup your conversion script.
You should now see your breakpoints load, and get hit during the indexing of content.

For information about Pre or Post Conversion scripts, see the following:-