F# CTP and Silverlight 2
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 1.9.6.2 version in the file path to 1.9.9.9 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.Coreand toSystem.Windowsby navigating directly to the Silverlight SDK binaries inC:\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
System.Windows.Controls.dllline<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
$(ProjectDir)calledsimplebuttonand copyC:\Program Files\FSharp-1.9.6.2\bin\FSharp.Core.dllinto it, along with theAppManifest.xamlabove - create an empty file
null.pyin the folder to keepchironquiet - 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$(ProjectDir) - 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!
No comments :
Post a Comment