What does Source: dotnetcli mean for .NET exception errors in Matlab?

3 views (last 30 days)
I am trying to use the kinesis .NET package from Thorlabs (https://www.thorlabs.com/software_pages/ViewSoftwarePage.cfm?Code=Motion_Control).
I have the Thorlabs Laser diode controller (model TLD001), a Thorlabs piezo control (model TPZ001) and a Thorlabs strain gauge reader (model TSG001) all connected to my PC through the USB port. I can operate all of these devices through the Kinesis software package, but I am interested in operating these devices through Matlab because I want my own custom interface and functionality. The libraries for the Kinesis control software is in the microsoft .NET framework. I have Microsoft .NET Framework 4.6.1 installed on my computer currently and the operating system is Windows 7 Enterprise.
In MATLAB, I run the following commands to load the .dll files:
asm = NET.addAssembly('c:\Program Files\Thorlabs\Kinesis\Thorlabs.MotionControl.GenericMotorCLI.dll');
dsm = NET.addAssembly('c:\Program Files\Thorlabs\Kinesis\Thorlabs.MotionControl.Tools.WPF.dll');
bsm = NET.addAssembly('c:\Program Files\Thorlabs\Kinesis\Thorlabs.MotionControl.TCube.LaserDiodeCLI.dll');
csm = NET.addAssembly('c:\Program Files\Thorlabs\Kinesis\Thorlabs.MotionControl.DeviceManagerCLI.dll');
I am also able to initialize some of the class methods from the libraries:
Thorlabs.MotionControl.DeviceManagerCLI.DeviceManagerCLI.BuildDeviceList()
List=Thorlabs.MotionControl.DeviceManagerCLI.DeviceManagerCLI.GetDeviceList()
Thorlabs.MotionControl.TCube.LaserDiodeCLI.LaserDiodeStatus
S=Thorlabs.MotionControl.TCube.LaserDiodeCLI.ThorlabsLaserDiodeSettings
However, when I try to access the libraries for the Laser Diode Controller, such as:
Thorlabs.MotionControl.TCube.LaserDiodeCLI.TCubeLaserDiode.DevicePrefix
I get thrown an error.
Message: External component has thrown an exception.
Source: dotnetcli
HelpLink:
This same error occurs whenever I try to call any method associated with the class:
Thorlabs.MotionControl.TCube.LaserDiodeCLI.TCubeLaserDiode
I don't understand the error. I think its related to the dotnetclient.dll? Please advise. Thank you!

Answers (3)

James
James on 27 Jul 2016
I have a K-cube and ran your (modified) code:
asm = NET.addAssembly('c:\Program Files\Thorlabs\Kinesis\Thorlabs.MotionControl.KCube.BrushlessMotorCLI.dll');
csm = NET.addAssembly('c:\Program Files\Thorlabs\Kinesis\Thorlabs.MotionControl.DeviceManagerCLI.dll');
Thorlabs.MotionControl.DeviceManagerCLI.DeviceManagerCLI.BuildDeviceList()
List=Thorlabs.MotionControl.DeviceManagerCLI.DeviceManagerCLI.GetDeviceList()
Thorlabs.MotionControl.KCube.BrushlessMotorCLI.KCubeBrushlessMotor
Which returned:
ans =
KCubeBrushlessMotor with properties:
DevicePrefix: 28
Which is what I expect from the Deice ID number.
P.S. I know nothing about dotNET or calling dotNET functions in Matlab. I'm just copy-pasting, and modifying your code.

Guillaume
Guillaume on 27 Jul 2016
CLI in the contest of .Net is usually the Command Language Infrastructure. However, since 'CLI' appears in the name of the Thorlabs assembly, they may have decided to use the abbreviation to mean something else.
In any case, the exception is thrown by the Thorlabs assembly, so the problem is with their code, or the way you use it. The error message shown by matlab is completely useless, you need to look at the ExceptionObject property of the exception thrown. See Net.NetException for an example of how to do that. The StackTrace property may tell you more.
However, if you want to create your own GUI using these library why aren't you writing it in directly in .Net (in C# / C++ / VB)? In my opinion, it's much easier and quicker to write a good looking GUI in .Net than matlab. You've got a lot more built-in controls available in .Net, you can handle a lot more user events, and it's going to look a lot more modern.

Yixuan Zhang
Yixuan Zhang on 27 Jun 2022
Hi, I recently also got this kind of error. It may be a bug of MATLAB for its version 2018a. I updated my version and everything goes fine. You can try it if you still need to solve this problem.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!