I get the error saying that the type initializer for threw an exception when trying to useMATLAB dll in visual studio. How to solve it?

7 views (last 30 days)
Dear experts, I'm trying to use matlab function in visual studio. After I build the dll files, I have a problem to run it in visual studio.
This is the main part of my code: using System.Threading.Tasks;
using System.Windows.Forms;
using MathWorks.MATLAB.NET.Utility;
using MathWorks.MATLAB.NET.Arrays;
using MathWorks.MATLAB.NET.WebFigures;
using DotNetProjectNative;
using DotNetProject;
using showImage;
using showImageNative;
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e)
{
showImage.Class1 t = new showImage.Class1();
t.showimage(openFileDialog1.FileName);
}
}
}
This is the error: {"The type initializer for 'showImage.Class1' threw an exception."}

Answers (0)

Community Treasure Hunt

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

Start Hunting!