[Ironpython-users] Ironpython cannot load .Net DLL

Petri Alapiessa Petri.Alapiessa at varian.com
Wed Apr 5 02:24:14 EDT 2017

It’s already there, 3. line. The error disappears when I add DLL to GAC. But it’s a workaround. I am still interested can this be fixed otherwise.

From: Slide [mailto:slide.o.mix at gmail.com]
Sent: 04 April 2017 17:54
To: Petri Alapiessa <Petri.Alapiessa at varian.com>; ironpython-users at python.org
Subject: Re: [Ironpython-users] Ironpython cannot load .Net DLL

Please try adding the Dependencies directory to the sys.path. You can do it like this:


On Tue, Apr 4, 2017, 07:52 Petri Alapiessa <Petri.Alapiessa at varian.com<mailto:Petri.Alapiessa at varian.com>> wrote:
My company uses .NET and has libraries to application interface. I would like to use python to invoke application functions. A prerequisite is that I can load .NET DLL that interacts with that application.
But I am stuck here, Ironpython cannot load one of the dependent DLL's or it's dependency.

My python script references Components.dll, which in turn references some other .NET DLL’s, including “Blaa.Blaa.Testing.Automation.dll”.
That is not found, see log below

Here is my Ironpython script:
import clr
import sys

from exceptions import SystemError, Exception
import System
import System.Reflection


from System.Reflection import ReflectionTypeLoadException

  from Components import Calculator
  calculator = Calculator()
  print Calculator.Ready()
except  System.Reflection.ReflectionTypeLoadException as e2:
  print e2.LoaderExceptions[0]
except Exception  as e2:
  print('Exception occurred: ' + e2.message)
System.IO.FileNotFoundException: Could not load file or assembly 'Blaa.Blaa.Testing.Automation, Version=, Culture=neutral, PublicKeyToken=bd317adc1d7d9856' or one of its dependencies. The system cannot find the file specified.
File name: 'Blaa.Blaa.Testing.Automation, Version=, Culture=neutral, PublicKeyToken=bd317adc1d7d9856'

=== Pre-bind state information ===
LOG: DisplayName = Blaa.Blaa.Testing.Automation, Version=, Culture=neutral, PublicKeyToken=bd317adc1d7d9856
LOG: Appbase = file:///C:/Program<file:///C:\Program> Files (x86)/IronPython 2.7/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\IronPython 2.7\ipy64.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Blaa.Blaa.Testing.Automation, Version=, Culture=neutral, PublicKeyToken=bd317adc1d7d9856
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

All dependencies should be in _Dependencies-folder. Similar script created as C# project works. IL Spy does not show any dependencies that should not be available.

Thanks for any help in helping to solve this! I did not yet find any help after several days of studies.

Best Wishes,

Petri Alapiessa

Ironpython-users mailing list
Ironpython-users at python.org<mailto:Ironpython-users at python.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20170405/2710b8a9/attachment.html>

More information about the Ironpython-users mailing list