Why does a class created through MATLAB Builder NE throw an exception at initialization?
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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
More Answers (0)
See Also
Categories
Find more on Deploy to .NET Applications Using MWArray API in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!