[Python.NET] Python for .NET load .dll

Tony Roberts tony at pyxll.com
Mon Jun 8 17:22:33 CEST 2015


Hi,

I seem to remember some problems possibly related to this... those binaries
you've found are quite old now. As a first set I would recommend checking
out the latest source from github and building the pythonnet binaries
yourself. It should be as simple as running "python setup.py install" (or
bdist_wheel/bdist_egg to build the wheel/egg if you prefer).

The git repo is here: https://github.com/pythonnet/pythonnet/
Or if you are using python 3 use this one:
https://github.com/renshawbay/pythonnet

Best regards,
Tony


On Mon, Jun 8, 2015 at 4:10 PM Brian Lloyd <brian.d.lloyd at gmail.com> wrote:

> You probably need to escape those backslashes, no? e.g.
>
> 'C:\\Program Files\\API\\Test.NET'
>
>
> On Mon, Jun 8, 2015 at 3:44 AM, Gianni Iannelli <giannicristian at msn.com>
> wrote:
>
>> Dear All,
>>
>>
>> I have a problem loading an external dll using Python through Python for
>> .NET. I have tried different methodologis following stackoverflow and
>> similar. I will try to summarize the situation and to describe all the
>> steps that I've done.
>>
>> I have a dll named for e.g. Test.NET.dll. I checked with dotPeek and I
>> can see, clicking on it, x64 and .NET Framework v4.5. On my computer I have
>> installed the .Net Framework 4.
>>
>> I have also installed Python for .NET in different ways. I think that the
>> best one is download the .whl from this website
>> http://www.lfd.uci.edu/~gohlke/pythonlibs/#pythonnet . I have downloaded
>> and installed: pythonnet‑2.0.0.dev1‑cp27‑none‑win_amd64.whl. I can imagine
>> that it will works for .NET 4.0 since*Requires the Microsoft .NET
>> Framework 4.0.*
>>
>>
>> Once I have installed everything, I can do these commands:
>>
>>
>> >>> import clr>>> import System>>> print System.Environmnet.Version>>> print System.Environment.Version4.0.30319.34209
>>
>> It seems work. Then, I have tried to load my dll typing these commands:
>>
>>
>> >>> import clr>>> dllpath= r'C:\Program Files\API\Test.NET'>>> clr.AddReference(dllpath)
>> Traceback (most recent call last):
>>   File "<pyshell#20>", line 1, in <module>
>>     clr.AddReference(dllpath)FileNotFoundException: Unable to find assembly 'C:\Program Files\API\Test.NET'.
>>    at Python.Runtime.CLRModule.AddReference(String name)
>>
>> I have also tried to add '.dll' at the end of the path but nothing
>> changed. Then, I have also tried different solutions as described in:
>>
>>
>>    -
>>    http://stackoverflow.com/questions/14633695/how-to-install-python-for-net-on-windows
>>    ,
>>    -
>>    http://stackoverflow.com/questions/13259617/python-for-net-unable-to-find-assembly-error
>>    - https://github.com/geographika/PythonDotNet
>>
>>
>> and much more.... Unfortunately, it doesn't work and I get different
>> errors. I know that exists IronPython but I was trying to avoid to use it.
>>
>>
>> Thanks for your help!
>>
>> _________________________________________________
>> Python.NET mailing list - PythonDotNet at python.org
>> https://mail.python.org/mailman/listinfo/pythondotnet
>>
>
>
>
> --
>  47 Lining    *Brian Lloyd, SVP Engineering*  Cloud Advisory and
> Development Services  M +1.540.845.2975 | E brian.lloyd at 47lining.com | W
> www.47lining.com  This message and any attachments are confidential and
> intended solely for the individual(s) or entity to which it is addressed.
> If you are not the intended recipient, do not read, copy or distribute the
> email or any attachments. Please notify the sender immediately by return
> e-mail.
>
>
>  _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> https://mail.python.org/mailman/listinfo/pythondotnet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20150608/5f05aedf/attachment.html>


More information about the PythonDotNet mailing list