开发者

ExcelDna & standalone F# installation

I have downloaded the F# zipped distribution (i.e., without the installer) on Windows and I have a difficulty using ExcelDna with it.

When I copy the FSharp.Core.dll and the powerpack ones into the directory of the ExcelDna files (xxx.dna and xxx.xll), and use code into the dna file (see below), it doesn't work (although there is no error message).

<DnaLibrary Name="FSharp Sample" Language="F#">
    <![CDATA[

 开发者_Go百科   namespace Foo

    module Bar =

      open ExcelDna.Integration
      let sayhello () = "Hello from F#"

      [<ExcelFunction(Category="FSharp Functions", Description="FSharp function to add numbers")>]
      let add x y = x + y

      let rec factorial = function 
        | x when (x > 1.0) -> (floor x) * factorial (x - 1.0)
        | _ -> 1.0

    ]]>
</DnaLibrary>

However it does work with the dlls in the directory, and using a reference to an F#-compiled library, as in :

<DnaLibrary>
    <ExternalLibrary Path="MyExcelDna.dll" />
</DnaLibrary>

Other languages (C# & VB) seem to work fine.

Has anyone used the ExcelDna tools with a zipped F# distribution ? Would anyone have any idea of what could be wrong ?

Many thanks for your help.


Is the Excel DNA library using CodeDOM to compile the F# code snippet?

If yes, then you'll need to make sure that the CodeDOM provider can find the fsi.exe executable (so that it can invoke it to do the compilation). By default, this uses some registry settings, so this may be a problem. You can see how the resolution works by looking at BinFolderOfDefaultFSharpCompiler in the sources in CompilerLocationUntils.fs.

Maybe adding the key fsharp-compiler-location to some app.config (not sure which one that should be though) could work.

Alternatively, you can try compiling the FSharp.Compiler.CodeDom.dll from the sources available at CodePlex and see if the CodeDom provider gets called (and with what arguments). Compiling just this single project shouldn't be difficult (it is probably easier to create new project and copy the source files there, because the project files available at CodePlex are customized and a bit confusing)


I would suggest you ask the question in one of the DNA groups: Govert (the author of ExcelDNA) is good at answering. http://groups.google.com/group/exceldna

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜