Can't get MWNumericArray out of c#

7 visualizaciones (últimos 30 días)
Dan
Dan el 7 de Oct. de 2016
Comentada: Para Kan el 23 de Oct. de 2019
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 comentario
SGH
SGH el 26 de Abr. de 2017
Editada: SGH el 26 de Abr. de 2017
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?

Iniciar sesión para comentar.

Respuestas (1)

Prasad Mendu
Prasad Mendu el 17 de Oct. de 2016
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 comentario
Para Kan
Para Kan el 23 de Oct. de 2019
Thanks Prasad! Your solution worked for me!

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by