为什么数组中的记录会导致heroku中的类型初始化程序错误?

时间:2017-05-29 14:52:54

标签: heroku f# typeinitializeexception

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

  

System.TypeLoadException:无法加载类型' FSI_0007 +测试[]'从   装配' FSI-ASSEMBLY,版本= 0.0.0.0,文化=中立,   公钥=空&#39 ;. at(包装器托管到原生)   System.Reflection.MonoMethod:InternalInvoke   (System.Reflection.MonoMethod,object,object [],System.Exception&)at   System.Reflection.MonoMethod.Invoke(System.Object obj,BindingFlags   invokeAttr,System.Reflection.Binder 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。

视觉工作室中的本地fsi不会发生这种情况。

1 个答案:

答案 0 :(得分:3)

这看起来非常像this bug in mono

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

另一种解决方法是将您的网站更改为使用fsproj,以便代码编译并作为可执行文件启动(而不是使用fsx文件通过F#interactive运行) - 我认为已编译的代码没有这个错误(或其他涉及单声道反射的潜在错误)。

相关问题