Message Boards Message Boards

NETTypeInfo error netexcptn: A .NET exception occurred

Posted 2 years ago

Hello, I'm evaluating Mathematica on Windows 10. I've created a simple C# dll, using .NET Core 3.1. This is the only code:

namespace TestLib
{
    public class Class1
    {
        public static long Test()
        {
            return 12;
        }
    }
}

In Mathematica I have an initialization cell:

Needs["NETLink`"]
InstallNET[];

and I seem to be able to load the assembly alright (at least it's not complaining)

In[3]:= LoadNETAssembly[" \
C:\\Users\\joes\\Documents\\TestLib\\bin\\Debug\\netcoreapp3.1\\\
TestLib.dll"]
Out[3]= NETAssembly["TestLib", 1]

But when I ask for info on the assembly, it's not happy:

NETTypeInfo[
 LoadNETAssembly[
  " C:\\Users\\joes\\Documents\\TestLib\\bin\\Debug\\netcoreapp3.1\\\
TestLib.dll"]]

NET::netexcptn: A .NET exception occurred: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at Wolfram.NETLink.Internal.CallPacketHandler.reflectAssembly(KernelLinkImpl ml)

The thing is, I can load the assembly that it says it can't find, and it doesn't complain:

In[5]:= 
LoadNETAssembly["System.Runtime, Version=4.2.0.0, Culture=neutral, \
PublicKeyToken=b03f5f7f11d50a3a"]

Out[5]= NETAssembly["System.Runtime", 2]

Am I doing something silly?

Edit: Adding image, because my slashes didn't format properly in text above.

NETTypeInfo Thanks,
Joe

POSTED BY: Joe Sauder
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