Reputation: 25
I am getting the
"The type initializer for 'tes.tambah' threw an exception.."
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MathWorks.MATLAB.NET.Arrays;
using tes;
namespace panggil_lib_matlab
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
tambah tbh = new tambah();
}
}
}
and this my Matlab Code:
function [ hasil ] = coba( a,b )
hasil = a+b;
end
I get error on this line: tambah tbh = new tambah();
and this is the 'InnerException' message:
System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWArray' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at MathWorks.MATLAB.NET.Arrays.MWArray.mclmcrInitialize2(Int32 primaryMode) at MathWorks.MATLAB.NET.Arrays.MWArray..cctor() --- End of inner exception stack trace --- at MathWorks.MATLAB.NET.Utility.MWMCR..cctor() --- End of inner exception stack trace --- at tes.tambah..cctor()
I use:
Can anyone help me?
Upvotes: 0
Views: 1169
Reputation: 41
Make sure that your application targets x64 rather than AnyCPU
Upvotes: 3