3

我正在将 F# 应用程序作为脚本部署到 heroku,但遇到了非常奇怪的问题。在下面指出的情况下,我收到以下错误,但在其他情况下没有:

System.TypeLoadException:无法从程序集“FSI-ASSEMBLY,版本=0.0.0.0,文化=中性,PublicKeyToken=null”加载类型“FSI_0007+Test[]”。在(包装器托管到本机) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) 在 System.Reflection.MonoMethod.Invoke (System.Object obj,BindingFlags invokeAttr, System.Reflection.Binder 活页夹,System.Object[] 参数,System.Globalization.CultureInfo 文化)<0x410a5830 + 0x000b7> in :0

错误案例:

type Test = { Test: string }
printfn "%A" [|{Test = "test"}|]  <--- error here

工作案例:

printfn "%A" [|"test"|]

type Test = { Test: string }
printfn "%A" {Test = "test"}

printfn "%A" [{Test = "test"}]

所以看起来我不能将记录放入数组中,但我可以将任何内置类型放入数组中。此外,我可以将记录放入列表中。记录本身就很好。

为什么记录加数组的组合会导致错误?

我在这里使用 buildpack: https ://github.com/SuaveIO/mono-script-buildpack

它使用mono-4.4.2.11。

Visual Studio 中的本地 fsi 不会发生这种情况。

4

1 回答 1

3

这看起来很像mono 中的这个错误

我不确定哪个版本的单声道受到此影响,并且错误讨论中的报告有点矛盾 - 但单声道 4.8.0 的最新稳定版本似乎至少适用于一个人......

另一种解决方法是更改​​您的网站以使用fsproj,以便将代码编译并作为可执行文件启动(而不是使用fsx通过 F# 交互运行的文件) - 我认为编译后的代码不会受到此错误(或其他涉及 Mono 的潜在错误)的影响反射)。

于 2017-05-29T17:32:06.567 回答