简体   繁体   English

使用F#创建Silverlight 3应用程序

[英]Creating Silverlight 3 applications with F#

Is there an easy way to create Silverlight 3 applications with F# (October CTP)? 是否有使用F#(十月CTP)创建Silverlight 3应用程序的简便方法? I have seen the F# for Silverlight , but that only works with the May CTP. 我已经看到了SilverlightF# ,但这仅适用于May CTP。

I am using Visual Studio Integrated Shell 2008. 我正在使用Visual Studio Integrated Shell 2008。

It is possible to use the May CTP templates with the October CTP version of F# 可以将May CTP模板与F#的October CTP版本一起使用

Create your new project, then unload it and edit the hint path for the FSharp.Core.dll to point to the October CTP, 创建您的新项目,然后将其卸载并编辑FSharp.Core.dll的提示路径,使其指向十月份的CTP,

<HintPath>$(ProgramFiles)\fsharp-1.9.7.8\Silverlight\2.0\bin\FSharp.Core.dll</HintPath>

then reload the project and build. 然后重新加载项目并进行构建。

You do have to package the .xap file manually by eg using the chiron tool (or just zipping and renaming) 您确实必须通过例如使用chiron工具手动打包.xap文件(或仅压缩和重命名)

The AppManifest.xaml file looks like AppManifest.xaml文件看起来像

<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 Files\\FSharp-1.9.7.8\\Silverlight\\2.0\\bin\\FSharp.Core.dll into it, along with the AppManifest.xaml above 在$(ProjectDir)中创建一个文件夹,以保存要打包的所有文件,并将C:\\ Program Files \\ FSharp-1.9.7.8 \\ Silverlight \\ 2.0 \\ bin \\ FSharp.Core.dll和AppManifest.xaml复制到其中以上

Create an empty file null.py in the folder to keep chiron quiet if you are using that tool 如果使用该工具,请在文件夹中创建一个空文件null.py以保持Chiron安静

Add the following post-build steps 添加以下构建后步骤

cd $(ProjectDir)
copy /y $(OutDir)$(TargetFileName) [your directory with all the output] 
"C:\Program Files\IronPython 2.0\Silverlight\bin\chiron.exe" /d:[your directory with all the output] /z:app.xap

Create a test page to load app.xap 创建一个测试页面以加载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 Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\ProjectTemplatesCache\\FSharp\\Silverlight\\SilverlightLibrary3.zip\\SilverlightLibrary.fsproj (and probably the version of the file in C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\ProjectTemplates\\FSharp\\Silverlight\\SilverlightLibrary3.zip just to be certain). 您可以通过在C:\\ Program Files \\ Microsoft Visual Studio 9.0 \\ Common7 \\ IDE \\ ProjectTemplatesCache \\ FSharp \\ Silverlight \\ SilverlightLibrary3.zip \\ SilverlightLibrary中编辑模板,对找到FSharp.Core.dll所需的提示路径进行永久性修复。 fsproj(当然可以确定C:\\ Program Files \\ Microsoft Visual Studio 9.0 \\ Common7 \\ IDE \\ ProjectTemplates \\ FSharp \\ Silverlight \\ SilverlightLibrary3.zip中文件的版本)。

And a working proof of concept (source and everything bundled into the xap) here . 和(捆绑在XAP源和一切)概念的工作证明这里

看来我必须等待VS 2010

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM