I have used the Matlab .NET Builder to generate a dll containing user defined Matlab functions. I have tested the dll in a standalone console application using Visual Studio 2005 and the dll can be referenced and the functions made available within the .NET environment with no problem.
Problems arise when I try to reference the same dll in a VS application which is used as a RobotStudio (5.10) add in. When the program tries to create an instance of this class, RS crashes.
I have included the following in the RobotStudioinAddins directory:
matFuncts.dll (user generated dll from Matlab .NET Builder, unable to call instance without RS crashing)
matFuncts.ctf (also genertaed from Matlab .NET builder)
myAddin.dll (RS addin developed in Visual Studio - contains static void AddinMain() and also references matFuncts.dll)
Are there any known issues with user defined dlls, which are referenced in a RS addin?? Any help appreciated…
All RS cares about is the method static void AddinMain(). The rest is up to the add-in itself, i.e. I don’t believe this error is directly related to RobotStudio.
I suggest you try to debug your dll using Visual Studio. In your Visual Studio project you can define RobotStudio as the external program to start, see picture below. Just ensure that your dll is copied to the RobotStudio/bin/addins folder as a post-build step.
I’ve tried to debug the dll as you suggested but for some reason, there is no exception thrown. I can try to give some details about where I’ve made the call and what happens with RS. There are 2 scenarios I have come across when trying to instantiate the user generated dll (myFuncts.dll) from Matlab .NET Builder:
Trying to instantiate myFuncts.dll from UserControl1 (button click) or from CommandBarButton:
public static void AddinMain(){
ToolWindow tw=new ToolWindow;
UserControl1 uc = new UserControl1;
tw.Control=uc;
}
Although RS starts and displays the correct values in the textbox, problems occur when I try to load a station. The virtual controller starts but the RS then freezes and the station is not loaded.
As you say Henrik, this may not be a RS problem, and I am also in contact with Mathworks support to see if they can shed some light on the issue.
Just to repeat…there are no problems when the Matlab generated dll (myFuncts.dll) is called and instantiated from a console application. The problems described are only experienced within the public static void AddinMain() method. Because the dll causes no problems in the console application, Mathworks believe it may be an RS problem…
Is it possible to test the addin dll as a console application or in some other application to determine what is causing the problem?
Unless there is a dependency from your dll you RobotStudio I suppose you can use it from any piece of software, independent of RobotStudio, such as for example a console application.
Unfortunately the crash dumps are empty (zero byte files).
Any chance you can try to run the addin under RS 2008? The error handling and dump generation has been much improved there…
I have attached an RS addin project, which uses the Matlab generated dll.
2008-05-29_134430_randomNumberRS.zip
Before using this dll (RMtest.dll), a matlab runtime compiler must be installed on the target machine. This enables the Matlab generated dll to run without having Matlab installed. I have emailed this to you both as the installer file is too large to post on the forum.
The class call is as follows:
RMtestclass rmt = new RMtestclass();
randMult = rmt.randomMultiplier(2, rob, lin);
The RMtest class has one method, randomMultiplier(). This method takes 2 vector inputs (rob and lin), multiplies them by a random number and outputs the result. Some data conversions are required to get the results from Matlab arrays to native .NET arrays.
It is possible to instantiate the class and return the results in a console application but the same code causes RS to crash when used in as an addin.