Using Instrument plugins in non-testplan programs

In order to avoid having to re-create Instrument I/O in applictions that are not OpenTAP testplan based I want to re-use/consume some instrument plugins.

I created a simple Console app referencing a simple SCPI Instrument plugin DLL and OpenTAP nuget package.

Creating the object and setting the VISA address works wo any error but the base.Open() in the Open() method call throws an error: System.Exception: ‘Could not create VISA connection’.
Code:
MyInstrument1 myInstrument1 = new MyInstrument1();
myInstrument1.VisaAddress = “GPIB0::17::INSTR”;
myInstrument1.Open();

The plugin works fine when used in a testplan/teststep and I can communicate with the device using ConnectionExpert/InteractiveIO.

Any ideas?

Hi @GoranJohnsson,

I think this is because OpenTAP puts all those dependencies in sub folders, so a standard .NET application cannot just resolve those paths.

To fix it you can force the plugin manager to initialize the DLL resolver using this code:

OpenTap.PluginManager.DirectoriesToSearch().ToList()

In OpenTAP 9.26 (upcomming release) you will be able to call, but its essentially the same.

OpenTap.PluginManager.Initialize();
1 Like

Thanks!
Thats seems to fix the problem. Not obvious.
DirectoriesToSearch is a property, not a method.

I think main reason for the error was the VISA ResourceManager couldnt be started/found so no VISA session could be created.

DirectoriesToSearch is a property, not a method.

This is because we just need the static constructor to be invoked. So doing anything with the PluginManager will do it, but nothing else is really safe to just call. That is why we are adding PluginManager.Initialize in the next version.