C# .NET Trouble initializing libraries required by Builder NE

28 views (last 30 days)
Hi,
Please could somebody help me, I feel like I've tried everything and don't know how to stop the exception at the bottom of this message from occuring.
I have a setup on Amazon Web Services. I have the Matlab Compiler Runtime 64 and x84 installed to c:\Programs\.
I have a website in .NET 4.0 that gives the exception below.
When I run a console app with the same code it works fine.
This is for my MSc and would really really appreciate some help as I've been trying to get this working for the last 48hrs and its getting me upset :'-( !
Before people ask I've tried it with just x64 or x84 and again I get the same problem. I have also tried to use a MWNumericalArray instead of MWArray but to no avail.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Trouble initializing libraries required by Builder NE.
Source Error:
Line 19: protected void Button1_Click(object sender, EventArgs e) Line 20: { Line 21: MWArray a = 7; Line 22: Response.Write(a.ToString()); Line 23: }
Source File: c:\ml5\Default.aspx.cs Line: 21
Stack Trace:
[Exception: Trouble initializing libraries required by Builder NE. ] MathWorks.MATLAB.NET.Utility.MWMCR..cctor() +1046
[TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception.] MathWorks.MATLAB.NET.Arrays.MWArray..cctor() +185
[TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWArray' threw an exception.] MathWorks.MATLAB.NET.Arrays.MWArray.op_Implicit(Double scalar) +29 _Default.Button1_Click(Object sender, EventArgs e) in c:\ml5\Default.aspx.cs:21 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3707
-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

Accepted Answer

Friedrich
Friedrich on 13 Aug 2012
Edited: Friedrich on 13 Aug 2012
Hi,
normally one would create a .exe.config file with the same name as your application and put in the following lines:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
Lets say your app name is test.exe. Put the above lines into a text.exe.config file. Then run your application.
The MWArray.DLL was built with .NET 2.0 and due some .NET policies you must allow the 4.0 runtime to load older .NET runtimes if needed. Thats what the above file does.
The matlab.exe in your MATLAB installation has this file too.
Since your run a webserver you can't proceed that easy. There must be a setting somewhere where you can allow the webserver to load older CLR if needed.
  2 Comments
Friedrich
Friedrich on 13 Aug 2012
Not 100% but: I think for ISS you need to change (or create a new) applicationpool settings . If I remember correctly you'd need to set the "Managed pipeline mode" to "Classic".
Mark
Mark on 13 Aug 2012
You are wonderful!! I was so close to tears, the magic bit was the applicationpool settings.
Thank you so so much.
I genuinely cannot thank you enough.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!