dmoler

Debugging a Custom Delivery Channel Plug-In

Blog Post created by dmoler Employee on Oct 14, 2009

Writing a custom delivery channel is the most popular way of programmatically extending PI Notifications; but debugging these plug-ins can be a bit tricky.  Two common problems are 1) not running the same version of the plug-in that is loaded in Visual Studio and 2) not having remote debugging configured.

 

To ensure you are running the correct version, it is important to understand how the plug-ins are loaded.  When a process using the AFSDK requires a plug-in, the AFSDK downloads the version registered on the current AF server.  This version of the plug-in is loaded for the life of the process.  So if a new plug-in (or new version of a plug-in) is registered on the AF server, any running process will need to be restarted to load & use it.  Thus a running PI Notifications Service or PI System Explorer will need to be restarted to get the new plug-in.

 

In the early stages of developing a delivery channel, most debugging can be done with a simple test harness.  This might be a command line tool that accesses properties or a simple form that loads a UI control.  The Test() method can be tested and debugged this way, too.  When you are further along, you can test the UI elements in the PI System Explorer (PSE) by registering your plug-in with AF and (re)starting PSE.  Then you can use the Visual Studio "Attach to Process" feature (under the Debug menu) and select the "AFExplorer.exe" process.  If you don't have PSE installed on your development machine, you will need to use remote debugging.

 

If the PI Notifications Service runs locally on the development machine, simply set the service to run under your user account, then attach to it as described previously for PSE.  If you are running remotely, you will need to install the Visual Studio Remote Debugger on the machine running PI Notifications Service.  When you have a new build of your delivery channel, you will need to:

 

1.       register the new plug-in dll on the AF Server with regplugin

 

2.       copy the debug symbols (the pdb file generated with the dll) into C:\WINDOWS\Symbols\dll on the PI Notifications machine

 

3.       (re)start the PI Notifications service

 

I use a batch file that performs these steps to save time.  When all that is done and you want to debug the Send() method:

 

On the machine running the PI Notifications Service:

 

1.       run the Visual Studio Remote Debugger (you might need to delegate permissions to the account running Visual Studio depending on your security setup)

 

On the development machine:

 

2.       run "Attach to Process" in Visual Studio in the Debug menu

 

3.       in the "Qualifier" field, select Browse

 

4.       in the pop-up you should find the PI Notifications Service machine running the Remote Debugger

 

5.       select OK, then find "PIAnalyticsProcessor.exe" in the Process list and click Attach

 

If all goes well, the debugging symbols will be loaded and you will be able to set breakpoints that will be hit when a notification is triggered.

Outcomes