Feb 2010: This post is probably obsolete as we're coming up on Silverlight 4.0, so I've not retested. You might get away with changing the 188.8.131.52 version in the file path to 184.108.40.206 now.
Tinkering with my silverlight/IronPython planetarium clock, I find that the bulk of the errors I'm making are in units of measure -- is this angle in degrees, radians, hours or days? This is just the thing that F# CTP has built in features to cope with. So, proving the concept of Silverlight with F#...
Google turns up a bunch of references, some assuming a full Visual Studio while I'm developing on a laptop with just IronPython Studio and F# part of the time; others slightly out of date (still referring to
System.Windows.Controls.dll from the beta).
The latter, John Liao's post, looked promising, though, so I duplicated it thus--
- New F# library; paste the code in to the autogenerated Module1.fs
- Remove all references supplied by default
- Add a reference to
System.Windowsby navigating directly to the Silverlight SDK binaries in
C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies-- at this point you can also add any others you're going to want
- Use the suggested AppManifest.xaml without the
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" RuntimeVersion="2.0.31005.0" EntryPointAssembly="SilverLightFSharp" EntryPointType="SilverLightFSharp.MyApp"> <Deployment.Parts> <AssemblyPart x:Name="SilverLightFSharp" Source="SilverLightFSharp.dll" /> <AssemblyPart x:Name="FSharp.Core" Source="FSharp.Core.dll" /> </Deployment.Parts> </Deployment>
- create a folder in
C:\Program Files\FSharp-220.127.116.11\bin\FSharp.Core.dllinto it, along with the
- create an empty file
null.pyin the folder to keep
- Add the following post-build steps
cd $(ProjectDir) copy /y $(OutDir)$(TargetFileName) simplebutton "C:\Program Files\IronPython 2.0\Silverlight\bin\chiron.exe" /d:simplebutton /z:simplebutton.xap
- Use the suggested
TestPage.html, putting it in
- Build project
- Load page in browser and enjoy
Note that the
FSharp.Core.dll assembly is crucial in the manifest, even though it's not needed as an explicit reference in the project at build time -- everything links happily with it as an implicit component for building -- but without it there in the manifest and the XAP, the Silverlight content fails to load, silently, without putting up anything into the error reporting
<div> as a cry for help!