Can't get MWNumericArray out of c#

조회 수: 15 (최근 30일)
Dan
Dan 2016년 10월 7일
댓글: Para Kan 2019년 10월 23일
I have this very simple test C# code that is supposed to get the number 24 into MATLAB
public MWNumericArray test() { int data = 24; MWNumericArray array = data; return array; }
When I run test from MATLAB I get this error:
Error using mbm.sqlApache_Cassandra/test (line 24) Message: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception. Source: MWArray HelpLink:
When I get the full errorcode from c# it looks like this:
{System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWArray' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception. ---> System.Exception: Trouble initializing libraries required by .NET Assembly.
at MathWorks.MATLAB.NET.Utility.MWMCR..cctor()
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Arrays.MWArray..cctor()
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Arrays.MWNumericArray.get__Inf()
at MathWorks.MATLAB.NET.Arrays.MWNumericArray..cctor()
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Arrays.MWNumericArray.op_Implicit(Int32 scalar)
at cassandra_sql.csql.test() in c:\Mercurial\MBM\c#\cassandra_sql\cassandra_sql\csql.cs:line 81}
Any idea what to do ?
  댓글 수: 1
SGH
SGH 2017년 4월 26일
편집: SGH 2017년 4월 26일
I have the same problem. I'm using VS 2015, compiling the .net assembly in x64, target .net 4.5.2, running matlab 2015 x64. Attaching the VS debugger to matlab the constructor for MWStructArray fails to instantiate. When I run my C# code from a unit test and write that same MWStructArray to a *.mat file (using a matlab function compiled into a .net assembly), the *.mat file loads the MWStructArray just fine in matlab. However, I can not get the MWStructArray straight up from my .net assembly. I ONLY have one installation of Matlab (v2015 x64), one installation of the Matlab runtime (v9 == v2015).
Has anyone been able to get an MWStructArray from a .net assembly?

댓글을 달려면 로그인하십시오.

답변 (1개)

Prasad Mendu
Prasad Mendu 2016년 10월 17일
One of the possible reasons for this error is the bitness mismatch between Visual Studio and the DLL. The Visual Studio has to be of 64-bit to run a 64-bit DLL. By default Visual Studio is a 32-bit application and while installing it you can check the option for 'x64'.
If you have not already done so, you can go to Configuration Manager check to see which option is selected 'x64' or 'x86'. You can also change the build configuration in Visual Studio to set the Target Platform to 'x64' instead of 'x86'.
  댓글 수: 1
Para Kan
Para Kan 2019년 10월 23일
Thanks Prasad! Your solution worked for me!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB Compiler SDK에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by