我正在将 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 不会发生这种情况。