Is it possible that the assembly has been compiled targeting specifically x86 and you're running a 64-bit process (or vice versa)?
2010/5/27 Bakalar, Matthew (NIH/CIT) [C] <bakala...@mail.nih.gov> > Thanks for the suggestion, I tried the bug fix suggested on the link you > posted. clr.LoadAssemblyFromFile does not throw an exception, but it also > doesn't return an assembly (in contrast, calling clr.LoadAssemblyFromFile > for a different assembly in the same directory returns an object that prints > itself as: <Assembly Target, Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null>) > > I have been picking through the log files, but I am inexperienced > interpreting them. The first log item shows an error, but after that I > receive two log items that claim "The operation was succesful. Bind result: > hr = 0x0." To confuse matters, at the end of these "successful" log entries > is the line: > > LOG: IJW assembly bind returned file not found. > > > > I looked up the error in the first log message, hr = 0x80070002. I found a > reference at > http://blogs.msdn.com/b/suzcook/archive/2003/05/29/57120.aspxthat suggests it > is actually a FileNotFoundException. Would this error ever > be thrown when the assembly did actually exist? As I said before, I'm using > it from this location with pure C# code. I have double checked my sys.path > to make sure it includes the folder where the assembly is located. Could the > problem be in the naming of the assembly? > > > > For reference sake, I am running windows vista x64. > > > > Thanks > > > > Matthew Bakalar > > > > The following items are logged when I attempt to load the problem assembly: > > > > *** Assembly Binder Log Entry (5/27/2010 @ 4:39:16 PM) *** > > > > The operation failed. > > Bind result: hr = 0x80070002. The system cannot find the file specified. > > > > Assembly manager loaded from: > C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll > > Running under executable > C:\Users\bakalarmh\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\Microsoft\IronPython > Tools for Visual Studio\0.2\RemoteScriptFactory.exe > > --- A detailed error log follows. > > > > === Pre-bind state information === > > LOG: User = NIH\bakalarmh > > LOG: DisplayName = MathNet.Iridium, Version=2008.8.16.470, Culture=neutral, > PublicKeyToken=c061a3ec32cc0c6f > > (Fully-specified) > > LOG: Appbase = > file:///C:/Users/bakalarmh/AppData/Local/Microsoft/VisualStudio/10.0/Extensions/Microsoft/IronPython > Tools for Visual Studio/0.2/ > > LOG: Initial PrivatePath = NULL > > LOG: Dynamic Base = NULL > > LOG: Cache Base = NULL > > LOG: AppName = RemoteScriptFactory.exe > > Calling assembly : (Unknown). > > === > > LOG: This bind starts in default load context. > > LOG: No application configuration file found. > > LOG: Using host configuration file: > > LOG: Using machine configuration file from > C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. > > LOG: Post-policy reference: MathNet.Iridium, Version=2008.8.16.470, > Culture=neutral, PublicKeyToken=c061a3ec32cc0c6f > > LOG: The same bind was seen before, and was failed with hr = 0x80070002. > > ERR: Unrecoverable error occurred during pre-download check (hr = > 0x80070002). > > > > *** Assembly Binder Log Entry (5/27/2010 @ 4:39:16 PM) *** > > > > The operation was successful. > > Bind result: hr = 0x0. The operation completed successfully. > > > > Assembly manager loaded from: > C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll > > Running under executable > C:\Users\bakalarmh\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\Microsoft\IronPython > Tools for Visual Studio\0.2\RemoteScriptFactory.exe > > --- A detailed error log follows. > > > > LOG: IJW explicit bind. File path:C:\Users\bakalarmh\Documents\NIH Dropbox\My > Dropbox\Target\Target\bin\Debug\MathNet.Iridium.DLL. > > LOG: IJW assembly bind returned file not found. > > > > *** Assembly Binder Log Entry (5/27/2010 @ 4:39:16 PM) *** > > > > The operation was successful. > > Bind result: hr = 0x0. The operation completed successfully. > > > > Assembly manager loaded from: > C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll > > Running under executable > C:\Users\bakalarmh\AppData\Local\Microsoft\VisualStudio\10.0\Extensions\Microsoft\IronPython > Tools for Visual Studio\0.2\RemoteScriptFactory.exe > > --- A detailed error log follows. > > > > LOG: IJW explicit bind. File path:C:\Users\bakalarmh\Documents\NIH Dropbox\My > Dropbox\Target\Target\bin\Debug\MathNet.Iridium.dll. > > LOG: IJW assembly bind returned file not found. > > > > > > > > > > > > > > *From:* Curt Hagenlocher [mailto:c...@hagenlocher.org] > *Sent:* Thursday, May 27, 2010 4:14 PM > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Internal Assembly Dependency > > > > The bug at > http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=26793 suggests > you might have success with clr.LoadAssemblyFromFile. Otherwise, you might > be able to use the Fusion log viewer ( > http://msdn.microsoft.com/en-us/library/e74a18c4(VS.80).aspx) to debug the > assembly load process. > > 2010/5/27 Bakalar, Matthew (NIH/CIT) [C] <bakala...@mail.nih.gov> > > In response to Lukas: > > I copied all of the assemblies, along with the script, to one folder. I > attempted to add a reference to MathNet.Iridium and received the following > error: > > > > >>> clr.AddReferenceByPartialName('MathNet.Iridium') > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > IOError: System.IO.IOException: Could not add reference to assembly > MathNet.Irid > > ium > > at > Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[] arg > > s, Boolean& shouldOptimize) > > at > IronPython.Runtime.Types.BuiltinFunction.BuiltinFunctionCaller`2.Call1(Cal > > lSite site, CodeContext context, TFuncType func, T0 arg0) > > at > System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite s > > ite, T0 arg0, T1 arg1, T2 arg2) > > at > IronPython.Runtime.Types.BuiltinFunction.BuiltinFunctionCaller`2.Call1(Cal > > lSite site, CodeContext context, TFuncType func, T0 arg0) > > at > IronPython.Compiler.Ast.CallExpression.Invoke1Instruction.Run(InterpretedF > > rame frame) > > at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame > frame) > > at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, > T1 a > > rg1) > > at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx) > > at IronPython.Compiler.PythonScriptCode.Run(Scope scope) > > at > IronPython.Hosting.PythonCommandLine.<>c__DisplayClass1.<RunOneInteraction > > >b__0() > > > > This leads me to believe IronPython is having trouble loading this > particular assembly, but I cannot decode the error message. Have you ever > seen this trace before? > > > > In Response to David: > > I tried the solution you suggested with no luck. The error message I > receive is the same. I suspect that the hint I've provided above might lead > us to a solution. > > > > Thanks All, > > > > Matthew Bakalar > > > > *From:* Lukas Cenovsky [mailto:cenov...@bakalari.cz] > *Sent:* Thursday, May 27, 2010 2:48 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Internal Assembly Dependency > > > > Bakalar, Matthew (NIH/CIT) [C] wrote: > > Hello All, > > I am new to IronPython, relatively new to C#, and new to this list. I have > a C# assembly that I am attempting to access from IronPython. I am able to > load the assembly using: > > clr.AddReferenceToFileAndPath(mypath) > > without any problems. I can then import the classes that reside within my > assembly as well, create instances of these classes, and call certain > methods on these instances. There are methods within this assembly that rely > on a reference to another assembly (MathNet.Iridium). When I attempt to call > these methods from my IronPython script, I receive the following error: > > IOError: [Errno 2] Could not load file or assembly 'MathNet.Iridium, > Version=2008.8.16.470, Culture=neutral, PublicKeyToken=c061a3ec32cc0c6f' or > one of its dependencies. The system cannot find the file specified. > > Now, I never added a reference to MathNet.Iridium in my script. However, I > assumed that the C# assembly that I am calling directly was compiled with a > reference to this other assembly, and that I would not have to explicitly > add a reference. When I create a test assembly entirely in C# that calls the > assembly I am attempting to call, and do not include a reference to the > MathNet.Iridium assembly, I am able to execute the code without problems. Do > I need to add a reference to the MathNet.Iridium assembly from within my > IronPython script even though I don't intend to access it directly? > > Thanks > > Matthew Bakalar > > > First, try to copy all necessary assemblies to the folder with your script > and use AddReference for all of them. If that works, you can experiment with > assemblies in different folders. > > Note, the path in AddReferenceToFileAndPath should be full path. > > -- > -- Lukáš > > > _______________________________________________ > Users mailing list > Users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > _______________________________________________ > Users mailing list > Users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > >
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com