3

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
9
  • Your question is a little vague. What is Test.TestMethods? Is MWArray a managed dll or native? How are you calling into MWArray? Can you post the code from TestMethodss' constructor? Commented Jun 20, 2013 at 17:21
  • this is a generated function by the matlab compiler. I can try to ildisasmble it.. Commented Jun 20, 2013 at 17:26
  • Hmm well just make sure you've copied over ALL dependencies into your current working directory (eg. MWArray might have a dependency on one of the other dlls present in the matlab folder). Try copying over all the dlls and see if that makes a difference. Commented Jun 20, 2013 at 17:29
  • Tried the TestNative Dll as well. Same thing. Commented Jun 20, 2013 at 17:43
  • <offtopic>Have you tried ilnumerics.net? I never touched the whole Matlab compiler thing again and use only pure managed code since then. little reason to continue to torture yourself ... just my 2C</offtopic> Commented Jun 20, 2013 at 17:48

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

My application is targeted for .NET framework v4.6.1 and it crashes exactly at the point where a new object for the class exported by MATLAB, is instantiated. Once I moved down to .NET framework v4.0, it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.