Message Boards Message Boards

GROUPS:

Avoid .NET/Link error in Visual Studio 2015?

Posted 1 month ago
187 Views
|
1 Reply
|
1 Total Likes
|

Hi All, Hope you are all fine. I am trying to maintain and extend the functionality of a very old C++ program (initially coded in 2009). It was using .NET/Link feature of Wolfram. However it does not have many documentation neither comments for the code. I've encountered a problem of compiling and running it with the error said:

Exception thrown: 'System.TypeLoadException' in mscorlib.dll
Exception thrown: 'System.DllNotFoundException' in Wolfram.NETLink.dll
Exception thrown: 'System.TypeInitializationException' in Wolfram.NETLink.dll
Exception thrown: 'System.TypeInitializationException' in [My Project].exe

I should mention that this happens in the very first beginning of the code:

kernel = nullptr;
kernel = MathLinkFactory::CreateKernelLink();

And the similar problem happens to me when I was trying to run the sample code from Wolfram official platform, it is a C# program though:

Exception thrown: 'System.TypeLoadException' in mscorlib.dll
Exception thrown: 'System.DllNotFoundException' in Wolfram.NETLink.dll
Exception thrown: 'System.TypeInitializationException' in Wolfram.NETLink.dll
'MathKernelApp.vshost.exe' (CLR v2.0.50727: MathKernelApp.vshost.exe)

I am not sure if this is a problem of environment setup or it is because of the incompatibility between Wolfram and Windows 10. Operating System: Windows 10 IDE: Visual Studio 2015 Target Platform Version: 10.0.16299.0 Platfomr Toolset: Visual Studio 2015 (v140)

A quick update: I have resolved problem in MathKernelApp provided by Wolfram by copying and pasting the ml64i4.dll into the Release folders. I thought it may help to my original problem but not. It is a separate problem and I still have no idea of how to fix the first one.

I have resolved the problem by myself. My original assumption is correct C# sample code has same problem as C++ program does. They are all missing ml64i4.dll file. For some reason, the old version Wolfram Mathematica will use default path to this file which is also called strong named. But apparently new version has changed. If you are trying to maintain an ancient code like my doing. It is worthwhile to try to copy ml64i4.dll and ml32i4.dll into the Debug/Release folder of the project.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract