Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Matlab Code from dot net

I've compiled a little program using matlab 2013 I can see in my dll: Test.TestMethods all my functions

I've added it as a reference to my dot net project, and added the MWArray dll from matlab bin\win64\v2.0 folder.

** Update: The app crushes at this line in the matlabe generated code:

mcr= new MWMCR("", ctfFilePath, embeddedCtfStream, true);

If I embed the ctf file - it will crush, if I don't embed it, it will throw an exception.

I've set my program to build against X64.

Once I try to create the object:

Test.TestMethods test = new Test.TestMethods();

My App crashes. I can only see in external Visual Studio instance:

Unhandled exception at 0x0000000001D36E60 (m_interpreter.dll). 
Access violation reading location 0x00000000A5CE3920.

I have no idea where to start....

EDIT1: this is the ctor (there is also a static cctor):

    .method public hidebysig specialname rtspecialname 
        instance void  .ctor() cil managed
{
  // Code size       20 (0x14)
  .maxstack  8
  IL_0000:  ldarg.0
  IL_0001:  call       instance void [mscorlib]System.Object::.ctor()
  IL_0006:  ldsfld     class [mscorlib]System.Exception Test.TestMethods::ex_
  IL_000b:  brfalse.s  IL_0013
  IL_000d:  ldsfld     class [mscorlib]System.Exception Test.TestMethods::ex_
  IL_0012:  throw
  IL_0013:  ret
} // end of method TestMethods::.ctor
like image 618
Dani Avatar asked Mar 08 '26 17:03

Dani


1 Answers

You cannot call MATLAB generated .NET libraries from .NET 4.5 assemblies, also it crashes when VS debugger is attached.

like image 150
Konstantin Tarkus Avatar answered Mar 11 '26 08:03

Konstantin Tarkus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!