English 中文(简体)
Creating Silverlight 3 applications with F#
原标题:

Is there an easy way to create Silverlight 3 applications with F# (October CTP)? I have seen the F# for Silverlight, but that only works with the May CTP.

I am using Visual Studio Integrated Shell 2008.

最佳回答

It is possible to use the May CTP templates with the October CTP version of F#

Create your new project, then unload it and edit the hint path for the FSharp.Core.dll to point to the October CTP,

<HintPath>$(ProgramFiles)fsharp-1.9.7.8Silverlight2.0inFSharp.Core.dll</HintPath>

then reload the project and build.

You do have to package the .xap file manually by e.g. using the chiron tool (or just zipping and renaming)

The AppManifest.xaml file looks like

<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
            RuntimeVersion="3.0.40818.0" 
            EntryPointAssembly="astroclock-fs" 
            EntryPointType="astroclock.fs.MyApp">
  <Deployment.Parts>
    <AssemblyPart x:Name="astroclock-fs" Source="astroclock-fs.dll" />
    <AssemblyPart x:Name="FSharp.Core" Source="FSharp.Core.dll" />
  </Deployment.Parts>
</Deployment>

where you fill in your own assembly name and entrypoint instead of mine

Create a folder in $(ProjectDir) to hold all the files to be packaged and copy C:Program FilesFSharp-1.9.7.8Silverlight2.0inFSharp.Core.dll into it, along with the AppManifest.xaml above

Create an empty file null.py in the folder to keep chiron quiet if you are using that tool

Add the following post-build steps

cd $(ProjectDir)
copy /y $(OutDir)$(TargetFileName) [your directory with all the output] 
"C:Program FilesIronPython 2.0Silverlightinchiron.exe" /d:[your directory with all the output] /z:app.xap

Create a test page to load app.xap

Build project

Load page in browser and enjoy

ADDED

You can make a permanent fix for the hint path needed to find FSharp.Core.dll by editing the template in C:Program FilesMicrosoft Visual Studio 9.0Common7IDEProjectTemplatesCacheFSharpSilverlightSilverlightLibrary3.zipSilverlightLibrary.fsproj (and probably the version of the file in C:Program FilesMicrosoft Visual Studio 9.0Common7IDEProjectTemplatesFSharpSilverlightSilverlightLibrary3.zip just to be certain).

And a working proof of concept (source and everything bundled into the xap) here.

问题回答

Looks like I got to wait for VS 2010.





相关问题
Silverlight Rich text box control

Our team decided that we need our own custom Rich text box control for Silverlight app we are developing. We looked at existing controls mentioned at A good rich text control for Silverlight but ...

Silverlight ImageBrush not rendering (with Bing Map Control)

I m trying to add an image to a Pushpin instance from the Silverlight Bing Map Control, but I can t seem to get it to render (the pushpin renders fine). This is probably a general WPF question rather ...

Silverlight OpenFileDialog DoEvents equivalent

I m processing large files after they are selected by the user. My code looks like the following: if (FileDialog.ShowDialog() == true) { // process really big file } This freezes up the UI so ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Silverlight, Updating the UI during processing

I have a simple silverlight multifile upload application, and i want to provide the user with some feedback, right now its only in a test phase and i dont have the webservice. Somehow i cant get the ...

Silverlight 3 - FindName returns null

This looks a bug to me.. Using Silverlight 3 and i have a user control defined in XAML and trying to access the object during runtime returns a null. <Grid> <common:CommonGridEditPanel x:...

silverlight 3 collection binding

Someone please help me understand why this binding does not work... I have a class called SelectionManager with a property called dates which is populated by a WCF service. The property is an ...

热门标签