I don't know why I never tried this earlier, but I have now and I've discovered an easier way to debug my plugins.
Some of you may have already known this, but I didn't and I thought I'd share in an effort to make everyone's lives a little better.
Previously, when debugging a Jiwa plugin, I'd always just put in a line of code System.Diagnostics.Debugger.Launch(); and System.Diagnostics.Debugger.Break(); which would cause the registered debugger (Visual Studio in my case) jump up and start debugging.
That itself was a huge step up from the bad old days of debugging VB Script, and that might be why I never bothered to explore what other ways there were. I sort of did have an inkling the newer way I'm about to show was possibly, as it's similar how I debug the services we have, but never invested any time into it.
The drawback of the Debugger.Launch() / Break() method is you need to edit the plugin and then logout of Jiwa, log back in and then perform the right actions to hit your breakpoint. Sometimes this is just darn inconvenient, particularly if you've got a lot of actions / steps to replay to get to the point / state you want to be.
Anyway, this new method is as follows - I'm using as an example a plugin which does stuff within the Sales Order form.
This is the plugin - nothing unusual here:
The plugin has on the Forms tab an entry for the Sales Orders form, as you'd expect. This plugin simply displays a messagebox when a sales order is being saved.
To debug this, Jiwa.exe needs to be running already.
Open Visual Studio and select the "Continue Without Code" option
Then, on the Debug menu, select Attach to Process
A dialog will appear - locate the Jiwa.exe process and Attach
Now, select the Open File tool (or use the File Menu, either way)
Now locate the source file for the plugin. This will be in the ProgramData folder, and you want the .cs or .vb file which is the same name as the plugin name. The folder path is C:\ProgramData\Jiwa Financials\Jiwa 7 then Jiwa version, then windows user, then SQL server name, then database name, then Plugins, then Jiwa user, then Compile then the plugin name. Select the file and press the Open button on the dialog
Visual studio will display the plugin code - locate where you want a breakpoint and click on the line of interest and press F9 to set a breakpoint
Then, back in Jiwa, perform an action to trigger the breakpoint - in my example I set a breakpoint in the Setup method of the FormPlugin class - so Visual Studio jumped in as soon as I opened the sales order form.
And from there you can step through the executions, inspect variables, add watches and all that good stuff.
Enjoy!