From MATLAB to ASP.NET Web Forms Application/Web deployment - How to solve 'System.Ty​peInitiali​zationExce​ption' error?

3 Ansichten (letzte 30 Tage)
I'm trying to get a simple addition function performed within MATLAB to work on a webpage with an ASP.NET Web Forms application, purely to see if the process works.
1. I use the Library Compiler to build the 'addNumbers.dll' along with the class 'AdditionClass' to instantiate .
2. Reference the 'addNumbers.dll' along with the 'MWArray.dll' in the the C#.
3. Run the web application, but a 'System.TypeInitializationException' in App_Web_XXX.dll errors occurs once the button to perform the addition is pressed.
MATLAB R2015a, x64 Windows 10. Changing the debug configuration to x64 within VS does not seem to solve it. Any help would be greatly appreciated.
'Add' button results in exception error and breaks.
Exception Detail: System.BadImageFormatException
Oddly enough, it does work with pretty much the exact same C# code and same .dll paths, except in a Windows Forms Application rather than a Web Form. This at least proves the correct .dll files are being referenced and the code is correct (presumably).

Akzeptierte Antwort

Friedrich
Friedrich am 28 Dez. 2016
Hi,
there are two pieces to the puzzle here. First the bittedness of the DLL you built and second the bittedness of the webserver. I assume you are using the ISS which VisualStudio starts for you when pressing play/run. Per default VS will host the 32bit ISS but you have a 64bit DLL which the webserver should load. In order to get this working you need to tell VS to start the 64bit ISS version. See here for how to do it. Basically go to Tools | Options | Projects and Solutions | Web Projects and check the "Use the 64 bit version of IIS Express…" option.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Compiler SDK finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by