[Ironpython-users] Ironpython cannot load .Net DLL

Slide slide.o.mix at gmail.com
Tue Apr 4 10:54:21 EDT 2017


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

sys.path.append('path/to/Dependencies')

On Tue, Apr 4, 2017, 07:52 Petri Alapiessa <Petri.Alapiessa at varian.com>
wrote:

> Hi,
>
> 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
>
>
> sys.path.append('D:\\tfs\\sandbox\\calculatordemo\\calculatordemo\\_Dependencies')
>
>
>
> from exceptions import SystemError, Exception
>
> import System
>
> import System.Reflection
>
>
>
> clr.AddReference('Components')
>
>
>
> from System.Reflection import ReflectionTypeLoadException
>
>
>
> try:
>
>   from Components import Calculator
>
>   calculator = Calculator()
>
>   calculator.Start()
>
>   print Calculator.Ready()
>
> except  System.Reflection.ReflectionTypeLoadException as e2:
>
>   print e2.LoaderExceptions[0]
>
> except Exception  as e2:
>
>   print('Exception occurred: ' + e2.message)
>
>
> --------------------------------------------------------------------------------------------------------------------------
>
> Output:
>
> System.IO.FileNotFoundException: Could not load file or assembly
> 'Blaa.Blaa.Testing.Automation, Version=3.0.0.0, Culture=neutral,
> PublicKeyToken=bd317adc1d7d9856' or one of its dependencies. The system
> cannot find the file specified.
>
> File name: 'Blaa.Blaa.Testing.Automation, Version=3.0.0.0,
> Culture=neutral, PublicKeyToken=bd317adc1d7d9856'
>
>
>
> === Pre-bind state information ===
>
> LOG: DisplayName = Blaa.Blaa.Testing.Automation, Version=3.0.0.0,
> Culture=neutral, PublicKeyToken=bd317adc1d7d9856
>
>  (Fully-specified)
>
> LOG: Appbase = 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=3.0.0.0,
> 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
> https://mail.python.org/mailman/listinfo/ironpython-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20170404/ad73f968/attachment.html>


More information about the Ironpython-users mailing list