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

Gianni Iannelli giannicristian at msn.com
Mon Jun 8 17:59:21 CEST 2015

Thanks! Is it working now! I think I have done some error trying different way of backslash and similar. I have added to the sys.path the folder where the libraries are (path without ending slash), and then, add. Now it's working.
Thank you very much

From: tony at pyxll.com
Date: Mon, 8 Jun 2015 15:22:33 +0000
To: pythondotnet at python.org
Subject: Re: [Python.NET] Python for .NET load .dll


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 sinceRequires 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.Version
4.0.30319.34209It 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>
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-errorhttps://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





Brian Lloyd, SVP Engineering

Cloud Advisory and Development Services

M +1.540.845.2975 | E brian.lloyd at 47lining.com | W www.47lining.com

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


Python.NET mailing list - PythonDotNet at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20150608/7bc8d0bd/attachment-0001.html>

More information about the PythonDotNet mailing list