<div>Arg; I see we&#39;ve now adopted the annoying <a href="http://python.org">python.org</a> convention of replies not going to the list by default. :(</div><div> </div><div>You can use ILDASM, ILSpy or Reflector to see what assemblies yours is dependent on. Now that Reflector costs money, ILSpy is probably the best option for a quick check (though Reflector may be worth paying for if you do a lot of .NET development).<br>
<br></div><div class="gmail_quote">On Tue, Jun 28, 2011 at 8:52 AM, Dave Peterson <span dir="ltr">&lt;<a href="mailto:dpeterson@broadwaytechnology.com">dpeterson@broadwaytechnology.com</a>&gt;</span> wrote:<br><blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class="gmail_quote">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;">Hi Curt,<u></u><u></u></span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;">I had actually tried ( 1 ) below first.  That is, change my sample code to this:<u></u><u></u></span></p><div class="im"><p class="MsoNormal"><span style="font-size: 10pt;">        import sys<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">        sys.path.append(r”D:\path\to\my”)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size: 10pt;">        import clr<u></u><u></u></span></p></div><p class="MsoNormal">
<span style="font-size: 10pt;">        clr.AddReference(‘dll’)<u></u><u></u></span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;">Which, while it changes the error message, still fails.   Here’s the new error message:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;">                IOError: System.IO.IOException: Could not add reference to assembly dll<u></u><u></u></span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;">                   at IronPython.Runtime.ClrModule.AddReference(CodeContext context, String name)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;">                   at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object reference)<u></u><u></u></span></p><p class="MsoNormal">
<span style="color: rgb(31, 73, 125); font-size: 11pt;">                   at IronPython.Runtime.ClrModule.AddReference(CodeContext context, Object[] references)<u></u><u></u></span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;">                   at Microsoft.Scripting.Interpreter.ActionCallInstruction’2.Run(InterpretedFrame frame)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;">                   …. <u></u><u></u></span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;">I’ve tried ( 2 ) as well, and while some of the known dependencies load successfully – showing that the process works – some do not.  This could mean I’m confused on my dependencies – is there a tool which will show what assemblies a given assembly requires?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 10pt;">-- Dave</span><span style="color: rgb(31, 73, 125); font-size: 11pt;"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color: rgb(31, 73, 125); font-size: 11pt;"><u></u> <u></u></span></p><div style="border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) currentColor currentColor; padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span style="font-size: 10pt;">From:</span></b><span style="font-size: 10pt;"> Curt Hagenlocher [mailto:<a href="mailto:curt@hagenlocher.org" target="_blank">curt@hagenlocher.org</a>] <br><b>Sent:</b> Tuesday, June 28, 2011 3:11 PM<br>
<b>To:</b> Dave Peterson<br><b>Subject:</b> Re: [Ironpython-users] Assembly references: file does not exist?<u></u><u></u></span></p></div><div><div></div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">
.NET doesn&#39;t generally load dependent assemblies just because they&#39;re in the same directory from which you&#39;re doing a LoadFrom. I seem to recall that there are two ways of handling this:<u></u><u></u></p></div>
<div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">1) Add the directory to sys.path and then use clr.AddReference (without the full path)<u></u><u></u></p></div><div><p style="margin-bottom: 12pt;" class="MsoNormal">
2) Explicitly load the dependencies first before loading the dependents.<u></u><u></u></p></div><div><p class="MsoNormal">On Tue, Jun 28, 2011 at 6:25 AM, Dave Peterson &lt;<a href="mailto:dpeterson@broadwaytechnology.com" target="_blank">dpeterson@broadwaytechnology.com</a>&gt; wrote:<u></u><u></u></p>
<div><div><p class="MsoNormal"><span style="font-size: 10pt;">Hello,<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;">I’m relatively new to IronPython and .Net, but reasonably familiar with Python.   I’m trying to write a .py script to use one of my employer’s .NET dlls but whenever I try to AddReferenceToFileAndPath() I get an error:<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;">        IOError: System.IO.IOException: file does not exists: D:\path\to\my\dll<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;">However, the DLL definitely exists at D:\path\to\my\dll and indeed works from there using my employer’s app.   <u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;">I’m using the newest IronPython (just downloaded from the site and installed today using the installer):<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;">        IronPython 2.7 (2.7.0.40) on .NET 4.0.30319.225<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;"> <u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;">My latest attempted code is as below, though I’ve tried a lot of various combinations:<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;">        import sys<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;">        sys.path.append(r”D:\path\to\my”)<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;">        import clr<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;">        clr.AddReferenceToFileAndPath(r”D:\path\to\my\dll”)<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;"> <u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;">That last line raises the exception mentioned above with a stack trace where the first two lines are both from the IronPython’s ClrModule.  I may be barking up the wrong tree here, but it leads me to believe that my entry DLL is trying to load another DLL and the system can’t find the other one, even though it is in the same directory as the first dll.   Here’s the first two lines of the stack trace (I can’t copy’n’paste off the work machine where this is happening due to security constraints.)<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;">        at IronPython.Runtime.ClrModule.AddReferenceToFileAndPath(CodeContext context, String file)<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;">        at IronPython.Runtime.ClrModule.AddReferenceToFileAndPath(CodeContext context, String[] files)<u></u><u></u></span></p></div><div><p class="MsoNormal">
<span style="font-size: 10pt;"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;">Thanks in advance,<u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;">-- Dave</span><span style="font-size: 10pt;"><u></u><u></u></span></p>
</div><div><p class="MsoNormal"><span style="font-size: 10pt;"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-size: 10pt;"> <u></u><u></u></span></p>
</div></div><p style="margin-bottom: 12pt;" class="MsoNormal"><br>_______________________________________________<br>Ironpython-users mailing list<br><a href="mailto:Ironpython-users@python.org" target="_blank">Ironpython-users@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/ironpython-users" target="_blank">http://mail.python.org/mailman/listinfo/ironpython-users</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div>
</div></blockquote></div><br>