[IronPython] AddReference to Silverlight toolkit assemblies

Jimmy Schementi Jimmy.Schementi at microsoft.com
Wed May 5 20:24:09 PDT 2010

Ah *duh*, though Microsoft.Scripting.Silverlight.dll calls ScriptRuntime.LoadAssembly on each AssemblyPart in the AppManifest.xaml, it does *not* do the same thing for DLLs in zip files referenced by ExtensionPart, since Silverlight only gives us a way of getting files out of a zip, not enumerating its contents.

So, to correct myself, if you're using ExtensionParts, you'll have to call clr.AddReference for each DLL you want loaded. The reason why you don't see the expected types is because IronPython doesn't know about them.

We could require that those zip files have a AppManifest.xaml, which would list the DLLs, and then we could parse that and load the DLLs. Though asking Silverlight to implement ZIP contents enumeration is probably the best =)


From: Lukas Cenovsky [mailto:cenovsky at bakalari.cz]
Sent: Wednesday, April 28, 2010 6:14 AM
To: Discussion of IronPython; Jimmy Schementi
Subject: Re: [IronPython] AddReference to Silverlight toolkit assemblies

Well, I was wrong when I said it worked. Here is the scenario:

I have necessary .dlls in separate file called SLToolkit.zip which I reference in AppManifest.xaml:

    <ExtensionPart Source="Microsoft.Scripting.zip" />
    <ExtensionPart Source="SLToolkit.zip" />

There are the following files in SLToolkit.zip:






I want to use ChildWindow control. It works when I use it in XAML and load the XAML with XamlReader. But it does not work when I want to load it from code. If fails on importing because ChildWindow is not in System.Windows.Controls namespace.

I put System.Windows.Controls.dll into .xap file and test the following in Silverlight REPL:

py> import System.Windows.Controls

=> None

py> dir(System.Windows.Controls)

=> ['Border', 'Button', 'Canvas', 'CheckBox', 'CleanUpVirtualizedItemEventArgs', ...]

py> clr.AddReferenceToFile('System.Windows.Controls.dll')

=> None

py> dir(System.Windows.Controls)

=> ['Border', 'Button', 'Calendar', 'CalendarBlackoutDatesCollection',

'CalendarDateChangedEventArgs', 'CalendarDateRange', 'CalendarMode',

'CalendarModeChangedEventArgs', 'CalendarSelectionMode', 'Canvas',

'CheckBox', 'ChildWindow', 'CleanUpVirtualizedItemEventArgs', ...]

It looks like the controls from System.Windows.Controls.dll are not merged into System.Windows.Controls namespace.

Is it bug or do I do something wrong?

-- Lukáš

Jimmy Schementi wrote:

When you use ExtensionPart, it calls Assembly.Load on each file in the zip file referenced, so you don't need to do clr.Addreference.

System.Windows.Data.dll and System.Windows.Controls.Data.dll are not DLLs in Silverlight; they are in the Silverlight SDK. So you'll have to package them up into a separate zip file which you include in your AppManfest, just like you did with the SLToolkit.zip.


From: users-bounces at lists.ironpython.com<mailto:users-bounces at lists.ironpython.com> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky
Sent: Tuesday, March 23, 2010 5:42 PM
To: users at lists.ironpython.com<mailto:users at lists.ironpython.com>
Subject: [IronPython] AddReference to Silverlight toolkit assemblies

Hi all,
I use Silverlight toolkit in my IronPython Silverlight app. To lower bandwidth, I put all necessary Silverlight toolkit .dlls into separate file called SLToolkit.zip which I reference in AppManifest.xaml:

    <ExtensionPart Source="Microsoft.Scripting.zip" />
    <ExtensionPart Source="SLToolkit.zip" />

This works nicely if I don't need to reference assembly already existing in Silverlight - e.g. I do


and use DataGrid. Unfortunately, when I need to reference PagedCollectionView from System.Windows.Data, this approach does not work. Trying

from System.Windows.Data import PagedCollectionView

fails on ImportError: Cannot import name PagedCollectionView. Doing

import System.Windows.Data

fails with AttributeError: attribute 'PagedCollectionView' of 'namespace#' object is read-only. When I try to add


if fails with: IOError: [Errno 2] could not find assembly: System.Windows.Data (check the Web server).

The only way how to make this work is to put System.Windows.Data.dll into .xap file and reference it with

from System.Windows.Data import PagedCollectionView

Is there a way to make it work when System.Windows.Data.dll is in the separate file? Or should I use another approach?


-- Lukáš



Users mailing list

Users at lists.ironpython.com<mailto:Users at lists.ironpython.com>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20100506/198d0530/attachment.htm>

More information about the Users mailing list