Why does a class created through MATLAB Builder NE throw an exception at initialization?

1 view (last 30 days)
I'm trying to get a simple Builder NE example working with Visual Basic.NET 2010. I've defined a simple .m file which doesn't take any arguments and returns a simple array. It's pasted below:
function out = pass_nums()
out = {1;2;3}
I've built this .m file into a .dll using the Builder NE, set up for .NET V3.5 and have called the class "pass_nums_class"
My code in Visual Basic is this:
Imports System
Imports System.Reflection
Imports MathWorks.MATLAB.NET.Arrays
Imports MathWorks.MATLAB.NET.Utility
Imports pass_nums
Public Class Class1
Public Shared Sub main()
Dim Output_Array As MWArray = Nothing
Dim Matlink As pass_nums_class = New pass_nums_class
Output_Array = Matlink.pass_nums()
End Sub
End Class
I've set up references to the MWarray.dll and the pass_nums.dll. When I run the code it throws an error on the line where I'm defining the object, Matlink. It says "The type initializer for 'pass_nums.pass_nums_class' threw an exception."
Does anyone have an idea why this error is occuring and what I can do to correct it?
Thanks, -Mark

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 14 Aug 2012
Hi,
I would suggest to add an "On Error" handler to the code, and take a look at the error message thrown. Without the error message it will be hard to guess what's up here...
Titus
  1 Comment
Mark
Mark on 15 Aug 2012
Thanks for the tip. Digging deeper into the error message, using the on error handler it turned out to be a problem acessing the mclmcrrt7_15.dll. For anyone else with the same issue the solution is documented here: http://www.mathworks.com/support/solutions/en/data/1-1IW46N/

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!