I used the MATLAB Compiler to generate a .NET Assembly
with a very little MATLAB code:
function output_arg = extest( input_arg1,input_arg2 )
output_arg = input_arg1+input_arg2;
end
I generated the dll with the wizard.
Within my Visual Studio project I added the reference to the generated dll (extest.dll
) and to the MATLAB Runtime dll (C:\Program Files\MATLAB\MATLAB Runtime\v92\toolbox\dotnetbuilder\bin\win64\v4.0\MWArray.dll
) as mentioned in the "Assembly Description".
This is my c# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MathWorks.MATLAB.NET.Utility;
using extest;
namespace DllTesting
{
class Program
{
static void Main(string[] args)
{
ExClass e1 = new ExClass();
}
}
}
It builds without errors an intelisense is working (so all references should be good from my understanding)
But when I launch it, the following exception gets thrown (on new ExClass()
):
An unhandled exception of type 'System.TypeInitializationException' occurred in DllTesting.exe
Additional information: The type initializer for 'extest.ExClass' threw an exception.
Any suggestions what is wrong with this code or whats missing?