[IronPython] IronPython Tools for existing project

Jimmy Schementi jimmy at schementi.com
Wed Jul 7 00:29:46 CEST 2010

On Mon, Jul 5, 2010 at 7:38 AM, Michael Foord <michael at voidspace.org.uk>wrote:

> Hello all,
> I'm working with a team on an IronPython Silverlight application. Some of
> the team develop with Windows and would like to use IronPython Tools for
> Visual Studio, especially for its debugging capabilities. This means I need
> to create a Visual Studio Solution and project(s) from the existing file
> layout.
> We would like to have the project checked in under version control and I'm
> aware that we'll probably need to manually manipulate the project files when
> we add files outside of visual studio.
> I can create the Visual Studio solution and project file and then manually
> manipulate the xml to add all the folders and individual files. So far so
> good. (Although perhaps not ideal having to add files individually -
> unfortunately I was away during the discussion about whether projects should
> be able to operate from the filesystem or have to explicitly include files.)

Yes, projects now have an explicit set of files which VS never magically
updates. Unfortunately "Show All Files" isn't supported on IronPython
projects today (well, really MPFProj <http://mpfproj.codeplex.com/> doesn't
support it), meaning there is no "add this sub-directory" option, so it's
really annoying to add a new set of files. Which means a script to update
the pyproj file is your best bet.

Dino and I were discussing a "refresh" button to enable on-demand updating,
but that kinda sucks for someone who just wants a directory browser, which
is sounds like you'd prefer? Personally I like the directory browser + regex
exclusion list, but I understand that others want a closer-to-VS experience.
Maybe there should be a toggle on the project that will put it in one or the
other modes? I say a project-setting because it wouldn't be good if a
explicit-project user created a project, and then it was opened by a
directory-browser user. =P

> Next I want to be able to launch our silverlight app from within visual
> studio in order to be able to debug.
> The html file is in a folder call "devcode". This has a subdirectory called
> "python", which becomes "python.xap" when served from chiron.
> I set the startup file for the project to "devcode\index.html" and the
> start directory to "devcode".
> When I launch the app with debugging from Visual Studio I get the message
> that Chiron has started on port 1322 and IE opens to the page
> http://localhost:1322/index.html
> Our html page opens (so far so good again), but unfortunately fails with
> the following error:
> Line: 31
> Error: Unhandled Error in Silverlight 2 Application
> Code: 2104
> Category: InitializeError
> Message: Could not download the Silverlight application. Check web server
> settings
> So it looks like Chiron is not building python.xap. How can I fix this?

I'm able to reproduce this too; all xap file requests are 500 errors. Must
be an issue with how VS is launching Chiron, as it works when I launch
Chiron with the same set of flags from cmd.exe. Let me poke around a bit
more ...

> The next problem is that the xaml designer doesn't work. It fails due to
> all the external assembly references used in our xaml. Now this itself isn't
> so much a problem as I know the xaml designer is ropey at the moment anyway
> - however Chiron is going to have the same problem. It needs to know which
> assemblies our app uses so that it can serve them (they are served
> externally rather than being included in the xap file and need an entry in
> the Chiron manifest.)

No need for putting an entry in the Chiron manifest; just create your own
AppManifest.xaml in the "python" directory and put your entries there. Then
put your assemblies somewhere relative to the "python" directory (like,
maybe, "bin"?), and use the same relative paths in the AppManifest.xaml,
like this:

<ExternalPart Source="bin/foo.zip" />

> If this is never going to work with VS tools I can move the assemblies into
> the xap file as we will *probably* need this later anyway in order to allow
> our application to be installed and run out of browser.

True, in SL3 ExternalParts did not work OOB, and I don't think that's
changed in SL4.

> However I had assumed I could "add a reference" to the assemblies we were
> using. The "add reference" dialog doesn't actually allow me to add any
> references... The only active button on it is "Cancel". Is it possible to
> add references to Silverlight assemblies used by our project? (And
> preferably have them picked up by both the xaml designer and by chiron.)

"Add Reference" does not work in any IronPython projects, mainly because
there is no standard place to put "clr.AddReference" ... at the top of the
main file? ... in a references.py file? This is more complicated in
Silverlight, as it first requires *either* that assembly to be in the XAP,
or as an ExternalPart, *or* as a zip-file script-tag, before
clr.AddReference is used. So for now, the reference must be manually added
depending on how you want it deployed. In your case, putting it in the
AppManifest.xaml will work fine for Chiron, though I'm almost certain the
XAML designer will not work; we'll have to extend the designer the same way
we're doing for WPF, except with knowledge of our Silverlight app-model.

> All the best,
> Michael
> --
> http://www.ironpythoninaction.com/
> http://www.voidspace.org.uk/blog
> READ CAREFULLY. By accepting and reading this email you agree, on behalf of
> your employer, to release me from all obligations and waivers arising from
> any and all NON-NEGOTIATED agreements, licenses, terms-of-service,
> shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure,
> non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have
> entered into with your employer, its partners, licensors, agents and
> assigns, in perpetuity, without prejudice to my ongoing rights and
> privileges. You further represent that you have the authority to release me
> from any BOGUS AGREEMENTS on behalf of your employer.
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100706/d49d0057/attachment.html>

More information about the Ironpython-users mailing list