Re: Problems with NETLink C#
- To: mathgroup at smc.vnet.net
- Subject: [mg120777] Re: Problems with NETLink C#
- From: "Oleksandr Rasputinov" <oleksandr_rasputinov at hmamail.com>
- Date: Tue, 9 Aug 2011 07:22:58 -0400 (EDT)
- Delivered-to: firstname.lastname@example.org
- References: <email@example.com>
On Mon, 08 Aug 2011 09:27:28 +0100, tarpanelli at libero.it <tarpanelli at libero.it> wrote: > Hello, > > I have Mathematica 7 and Visual Studio 2010 Professional edition. What I > am > trying to do is tho create a simple class in C# and use it in > Mathematica. > > In mathematica notebook I 've written the following code: > Needs["NETLink`"] > InstallNET > > but when I try to load the assembly > LoadNETAssembly ["F:\\My\\Mathematica\\mLink\\mNETLink\\mNETLink\\bin\ > \\Debug\\mNETLink.dll"] > > I got this error > > NET::netexcptn: A .NET exception occurred: > System.BadImageFormatException: > Could not load file or assembly 'file:///F: > \My\Mathematica\mLink\mNETLink\mNETLink\bin\Debug\mNETLink.dll' or one > of its > dependencies. This assembly is built by a runtime newer than the > currently loaded runtime and cannot be loaded. >[extra messages removed] > > any suggestion? > thanks > As I understand it, Mathematica 7 (and 8, for that matter) for Windows is compiled using Visual Studio 2005, so the most recent supported .Net runtime is version 2.0. You might try recompiling .NET/Link from source using Visual Studio 2010 if you want support for the newer .Net version 3.5 and 4.0 runtimes. I have not personally tried this, so I do not know how difficult it may be. Alternatively, you can install the .Net version 3.5 runtime alongside Visual Studio 2010 and target version 2.0 per the instructions given at <http://msdn.microsoft.com/en-us/library/bb398197(VS.100).aspx>. Assemblies compiled in this way will then be able to be loaded by ..NET/Link as supplied with Mathematica.