Adding External References

Dec 12, 2007 at 4:27 PM
Is it possible to add references to a project?
I mean, external .net dlls.
Coordinator
Dec 12, 2007 at 6:37 PM
In the current release it is not possible to add a ref via the IDE (of course you can edit the .pyproj by hand), because the Add References command is not implemented on the custom project.
Sorry :(

Pablo
Dec 12, 2007 at 7:25 PM
You'll need to edit the .pyproj as Pablo states above but you'll have to provide all the details yourself. You can find the details by seeing what is registered in your GAC (in the $system root$/assembly directory). Here is an example from how I connect to SQLite. You will obviously have to substitute the values for your application:

<Reference Include="System.Data.SQLite, Version=1.0.47.1, Culture=neutral, PublicKeyToken=db937bc2d44ff139">
<Name>System.Data.SQLite</Name>
<AssemblyName> System.Data.SQLite.DLL</AssemblyName>
<HintPath>..\..\..\..\..\..\..\Program Files\SQLite.NET\bin\System.Data.SQLite.DLL</HintPath>
<Private>True</Private>
</Reference>

I hope this helps,

--Chris
Dec 26, 2007 at 3:22 PM
Hi,

I'm coming for this thread:
http://www.codeplex.com/Thread/View.aspx?ProjectName=IronPythonStudio&ThreadId=19549

My newbie question:

Is there a way to add a dll to an Iron Python project without going through the GAC?

I've tried to register EARHTLib.dll (to control Google Earth) but gacutil answers """ Failure adding assembly to cache: Attempt to install an assembly without a strong name""" and I'm not sure how much time it will take me to understand how to create strong names, wrap it, link it and other extra surprises I can't even yet imagine.

Thanks for any hint :)
Dec 27, 2007 at 4:27 AM
This should be possible by using Interop (COM). I can't test this as I don't have access to my normal machine with all my tools but you would do something like this:

TlbImp.exe "C:\Program Files\Google\Google Earth\googleearth.exe" /out:"C:\Program Files\Google\Google Earth\Interop.EARTHLib.dll"
then:
import clr
import sys
sys.path.append("C:\Program Files\Google\Google Earth")
clr.AddReferenceToFile('Interop.EARTHLib.dll')

I don't know the structure of that API but this should get you started.
Dec 27, 2007 at 11:19 AM
Edited Dec 27, 2007 at 11:19 AM

Thanks Chris for your help, I really appreciate :)

I've done what you said and Iron Python Studio don't seem to complain now. Unfortunately I can't really see how to access the API.

in CPython I do this to automaticaly launch Google Earth and have the control over it:
"""
import win32com.client
ge = win32com.client.Dispatch("GoogleEarth.ApplicationGE")
"""

In visual C# express I do this to automaticaly launch Google Earth and have the control over it:
"""
IApplicationGE gEarth;
gEarth = new ApplicationGE();
"""

In Iron Python Studio I do (after adding the lines of code you've shown):

"""
from Interop.EARTHLib import *
gEarth = ApplicationGE
"""
IP St. doesn't complains when it meet "gEarth = ApplicationGE" but nothing happens (Google Earth is not launched).

Also if I do the same in the integrated shell I have:

>>>dir(gEarth)
'__class__', '__doc__', '__init__', '__module__', '__repr__'
>>>gEarth._init_
<method '_init_' of 'InstanceOps' objects>
>>>gEarth._module_
'Interop.EARTHLib in Interop.EARTHLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
>>>type(gEarth)
<type 'type'>

I've also tried to add () but whithout success:

>>>gE = ApplicationGE()
NoneType object is not callable

Thanks again for any hint you could provide.

Dec 27, 2007 at 1:04 PM
For information, I can also call IApplicationGE but I don't see how to acutaly use the methods and make the link with ApplicationGE

>>>ge=IApplicationGE
>>>dir(ge)
'AnimationController', 'AutoPilotSpeed', 'ElevationExaggeration', 'GetCamera', 'GetFeatureByHref', 'GetFeatureByName', 'GetHighlightedFeature', 'GetLayersDatabases', 'GetMainHwnd', 'GetMyPlaces', 'GetPointOnTerrainFromScreenCoords', 'GetRenderHwnd', 'GetTemporaryPlaces', 'HideDescriptionBalloons', 'IsInitialized', 'IsOnline', 'LoadKmlData', 'Login', 'Logout', 'OpenKmlFile', 'SaveScreenShot', 'SearchController', 'SetCamera', 'SetCameraParams', 'SetFeatureView', 'ShowDescriptionBalloon', 'StreamingProgressPercentage', 'TourController', 'VersionAppType', 'VersionBuild', 'VersionMajor', 'VersionMinor', 'ViewExtents', '__class__', '__doc__', '__init__', '__module__', '__repr__'
>>>ge.GetCamera
<method 'GetCamera' of 'IApplicationGE' objects>
>>>print ge.GetCamera
<method 'GetCamera' of 'IApplicationGE' objects>
>>>ge.VersionBuild
<property# VersionBuild on IApplicationGE>

How could I actualy see the vesion build for example?
Dec 27, 2007 at 4:43 PM
After doing my first instructions posted above, do this:

gEarth = ApplicationGEClass()

That should start up Google Earth for you. When it starts, it should show the version (it showed mine was not up to date and gave me a choice to upgrade).
Dec 27, 2007 at 4:49 PM
Just to give you a little bit of a start (other than just bringing up the app). Do this after the previous command (substitute city / place of choice):

search = gEarth.SearchController
search.Search("Columbus, OH")
Dec 27, 2007 at 6:04 PM
Great, thanks Chris :)
Dec 30, 2007 at 8:08 PM

PabloGaliano wrote:
In the current release it is not possible to add a ref via the IDE (of course you can edit the .pyproj by hand), because the Add References command is not implemented on the custom project.


Hi,

First, thanks for this IDE...it's great!

When you say that the Add Reference command is not implemented on the custom project, does that mean it's not possible to do with Visual Studio 2008 Shell-derived apps, or you just haven't implemented it in the current release?
Jan 22, 2008 at 7:03 PM
Edited Jan 22, 2008 at 7:04 PM
yawn........scratch

OK!