Re: NETLink:
- To: mathgroup at smc.vnet.net
- Subject: [mg71926] Re: [mg71867] NETLink:
- From: Todd Gayley <tgayley at wolfram.com>
- Date: Mon, 4 Dec 2006 06:38:57 -0500 (EST)
At 05:22 AM 12/1/2006, Zhe Hu wrote: >I read about driving LEGO Mindstorms RCX with .NET from >http://msdn.microsoft.com/coding4fun/hardware/robotics/article.aspx?articleid=877488 > >So I downloaded the assembly: C4F.LegoRcx.dll. Try to use it in Mathematica >by .NetLink, but failed. > >Needs["NETLink`"] >InstallNET[] >LoadNETAssembly["C:\\lego\\Debug\\C4F.LegoRcx.dll"] > >here is the error message from Mathematica: >""" >NET::netexcptn: A .NET exception occurred: System.BadImageFormatException: \ >The format of the file 'C4F.LegoRcx.dll' is invalid. >File name: "C4F.LegoRcx.dll" > at System.Reflection.Assembly.nLoad(AssemblyName fileName, String \ >codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean \ >throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark) > at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, \ >Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark) > at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence \ >securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm) > at Wolfram.NETLink.TypeLoader.LoadAssembly(String assemblyName) > at Wolfram.NETLink.Internal.CallPacketHandler.loadAssembly(KernelLinkImpl >\ >ml) > >LoadNETAssembly::noload: The assembly C:\lego\Debug\C4F.LegoRcx.dll either \ >was not found or could not be loaded. Hu, The problem is that C4F.LegoRcx.dll is built for the .NET Framework 2.0, and .NET/Link is configured to use .NET 1.1. To allow .NET/Link to use .NET 2.0, edit the file <Mathematica dir>/AddOns/NETLink/InstallableNET.exe.config. Add this line as the first <supportedRuntime> line: <supportedRuntime version="v2.0.50727" /> Now you will be able to load and use those RCX examples. Future releases of .NET/Link will by default use .NET 2.0 (or 3.0) on machines that have it installed. You will probably need to put the auxiliary DLLs (GhostAPI.dll, PbkComm32.dll, PbkUsbPort.dll) needed for those examples into a directory on your Windows PATH. There doesn't appear to be much documentation for the C4F.LegoRcx assembly, so use the NETTypeInfo function on assemblies, classes, and objects to see the types, methods, and properties available. Todd Gayley Wolfram Research