MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problems with NETLink C#

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120776] Re: Problems with NETLink C#
  • From: "Scot T. Martin" <smartin at seas.harvard.edu>
  • Date: Tue, 9 Aug 2011 07:22:47 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201108080821.EAA04661@smc.vnet.net>

My interpretation of error message:

- Current version of .NET environment is 4.

- Mathematica support .NET of 2 and earlier.

- I believe your message below is stating that the assembly you are trying to load was built with .NET of 2 or later.

- In this case, you'd need make the net assembly for .NET of 2 or earlier.

My confidence level on this diagnosis is 60%.



-----Original Message-----
From: tarpanelli at libero.it [mailto:tarpanelli at libero.it]
Sent: Monday, August 08, 2011 04:22
To: mathgroup at smc.vnet.net
Subject: [mg120776] Problems with NETLink C#

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.
File name: 'file:///F:
\My\Mathematica\mLink\mNETLink\mNETLink\bin\Debug\mNETLink.dll'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection)
   at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Wolfram.NETLink.TypeLoader.LoadAssembly(String assemblyName)
   at Wolfram.NETLink.Internal.CallPacketHandler.loadAssembly(KernelLinkImpl
ml)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].




  • Prev by Date: Re: Random prices from FinancialData
  • Next by Date: Some questions about a Mathematica script
  • Previous by thread: Re: Problems with NETLink C#
  • Next by thread: Re: Problems with NETLink C#