Skip to content

Literate.ProcessScriptFile Broken with "System.TypeLoadException: Method 'get_LineCount' in type 'lexer@289' from assembly 'FSharp.CodeFormat, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation." #277

Closed

Description

@Indy9000

Tried out with the default instructions on page F# Formatting: Literate programming
and updated the nuget packages to latest

Here's the build script

#I @"..\packages\FSharp.Formatting.2.7.5\lib\net40"
#I @"..\packages\FSharpVSPowerTools.Core.1.8.0\lib\net45"
#I @"..\packages\FSharp.Compiler.Service.0.0.87\lib\net45"
#r "FSharpVSPowerTools.Core.dll"
#r "FSharp.CodeFormat.dll"
#r "FSharp.Literate.dll"

open FSharp.Literate
open System.IO

let relative subdir = Path.Combine(__SOURCE_DIRECTORY__, subdir)

let file = relative "demo.fsx"
let output = relative "output/demo-script.html"
let template = relative "../templates/template-file.html"
Literate.ProcessScriptFile(file, template, output)

Error:

>System.TypeLoadException: Method 'get_LineCount' in type 'lexer@289' from assembly 'FSharp.CodeFormat, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
>   at FSharp.CodeFormat.CodeFormatAgent.ParseSource(String file, String source, FSharpOption`1 options, FSharpOption`1 defines) in c:\Tomas\Public\FSharp.Formatting\src\FSharp.CodeFormat\CodeFormatAgent.fs:line 389
>   at FSharp.Literate.ParseScript.parseScriptFile(String file, String content, CompilerContext ctx) in c:\Tomas\Public\FSharp.Formatting\src\FSharp.Literate\ParseScript.fs:line 197
>   at FSharp.Literate.Literate.ParseScriptFile[d](String path, FSharpOption`1 formatAgent, FSharpOption`1 compilerOptions, FSharpOption`1 definedSymbols, FSharpOption`1 references, FSharpOption`1 fsiEvaluator) in c:\Tomas\Public\FSharp.Formatting\src\FSharp.Literate\Main.fs:line 62
>   at FSharp.Literate.Literate.ProcessScriptFile(String input, FSharpOption`1 templateFile, FSharpOption`1 output, FSharpOption`1 format, FSharpOption`1 formatAgent, FSharpOption`1 prefix, FSharpOption`1 compilerOptions, FSharpOption`1 lineNumbers, FSharpOption`1 references, FSharpOption`1 fsiEvaluator, FSharpOption`1 replacements, FSharpOption`1 includeSource, FSharpOption`1 layoutRoots, FSharpOption`1 generateAnchors, FSharpOption`1 assemblyReferences) in c:\Tomas\Public\FSharp.Formatting\src\FSharp.Literate\Main.fs:line 152

Activity

  1. tpetricek commented on Apr 4, 2015

    @tpetricek
    Member

    Can you try referencing the F# Formatting library using the load script FSharp.Formatting.fsx (rather than referencing individual packages using #r)?

    Basically, I think that replacing the first 6 lines with the following should work:

     #load @"..\packages\FSharp.Formatting.2.7.5\FSharp.Formatting.fsx"
    

    If this works, it would be great if you can send a pull request to update the "typical literate setup" section in the documentation (so that it recommends to use the load script): https://github.com/tpetricek/FSharp.Formatting/blob/master/docs/content/literate.fsx

  2. Indy9000 commented on Apr 4, 2015

    @Indy9000
    ContributorAuthor

    This doesn't work. Looks like it's FSharpVSPowerTools.Core.1.8.0 that's breaking it.
    If I downgrade to version 1.7.0 it works.

  3. tpetricek commented on Apr 4, 2015

    @tpetricek
    Member

    cc @vasily-kirichenko @dungpa I suppose that having a dependency on "any version newer than 1.7.0" is causing the troubles here. Should we have a dependency on exact version? Or should we just include the current version of PowerTools DLL in the package? (I guess that's what @forki would suggest and I think that might save us some pain...)

  4. dsyme commented on Apr 6, 2015

    @dsyme
    Contributor

    This is busted for me too. I used

    nuget FSharp.Formatting 2.8.0
    nuget FSharpVSPowerTools.Core 1.7.0
    

    to work around it

  5. added a commit that references this issue on Apr 6, 2015
  6. added a commit that references this issue on Apr 7, 2015
    cf1acc1
  7. dungpa commented on Apr 7, 2015

    @dungpa
    Contributor

    Sorry, it was a non-obvious breaking change. I sent a PR to pin VFPT to v1.8.0 exactly.

  8. tpetricek commented on Apr 7, 2015

    @tpetricek
    Member

    Thanks!

  9. tpetricek commented on Apr 24, 2015

    @tpetricek
    Member

    Well, the dependencies are causing more pain here....

    Apparently, when we create FsiEvaluator from an FSI session, on .NET this loads whatever version of FSharp.Compiler.Service is already loaded (even if it is a different one (?)), but on Mono, this fails.

    So, if we download FSharp.Compiler.Service version 0.89, but VFPT requires 0.87, then creating FsiEvaluator fails because it cannot find it (and since this is in FSI session started by FAKE, I really don't know where I would put binding redirects...).

    I'll try fixing F# Compiler Service version too - basically, it looks like we should make sure that F# Formatting is compiled against the same version as VFPT (or ILMerge all the things...)

  10. tpetricek commented on Apr 24, 2015

    @tpetricek
    Member

    (@dsyme Tried to explain to me at F# eXchange how deal with references properly, but I still don't get it... so maybe I'm missing something here. A better solution would be nice.)

  11. matthid commented on Apr 24, 2015

    @matthid
    Member

    See #303

  12. matthid commented on Apr 24, 2015

    @matthid
    Member

    @tpetricek Is there a way to reproduce the issue, just updating FCS seems to work: See #304. Maybe we should add a testcase to make that fail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions