0

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:

  • Windows 8.1 64-bit
  • Visual Studio Ultimate 2012 (32-bit, I think)
  • Matlab R2015a 64-bit

Can anyone help me?

1
  • Improved some formatting and grammar, made title slightly more concise Commented Jun 3, 2015 at 23:28

1 Answer 1

3

Make sure that your application targets x64 rather than AnyCPU

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

Comments

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.