gpt4 book ai didi

F# Powerpack 的元数据无法将 FSharp.Core 识别为 F# 库

转载 作者:行者123 更新时间:2023-12-03 20:50:22 25 4
gpt4 key购买 nike

这是我用来隔离问题的测试代码:

open Microsoft.FSharp.Metadata
[<EntryPoint>]
let main args =
let core = FSharpAssembly.FromFile @"C:\Program Files\FSharp-2.0.0.0\\bin\FSharp.Core.dll"
let core2 = FSharpAssembly.FSharpLibrary
let core3 = System.AppDomain.CurrentDomain.GetAssemblies()
|> Seq.find (fun a -> a.FullName.Contains "Core")
|> FSharpAssembly.FromAssembly

core.Entities |> Seq.iter (printfn "%A")
0

所有三个 let 都应该给我相同的 FSharpAssembly。相反,所有 3 个都抛出 FSharp.Core 不是 F# 程序集的异常(下面的详细信息,为了便于阅读而重新格式化)。还有两条线索:

  1. 使用 core3 方法,我在测试 F# 程序集本身时遇到了同样的错误
  2. 在执行 #r "@C:\Program Files...\FSharp.Powerpack.Metadata.dll" 后,我没有在 FSI 收到错误。

有什么想法吗?我在旧的 XP VM 上使用 Visual Studio 2008、F# 2.0 和 F# Powerpack 2.0.0.0(2010 年 5 月 20 日)版本,但我认为它已更新到 SP3。

(我今天早上遇到 Powerpack 1.9.9.9 的错误,所以我升级到 2.0.0.0。我想如果 1.9.9.9 不能识别 F# 的 2.0.0.0 的程序集,那么可能是 Powerpack 2.0 中的错误修复。 0.0 会有帮助。)

Unhandled Exception: System.TypeInitializationException: 
The type initializer for 'Microsoft.FSharp.Metadata.AssemblyLoader' threw an
exception.
---> System.TypeInitializationException: The type initializer for
'<StartupCode$FSharp-PowerPack-Metadata>.$Metadata' threw an exception.
---> System.ArgumentException: could not produce an FSharpAssembly
object for the assembly 'FSharp.Core' because
this is not an F# assembly
Parameter name: name
at Microsoft.FSharp.Metadata.AssemblyLoader.Add(String name,Assembly assembly)
at <StartupCode$FSharp-PowerPack-Metadata>.$Metadata..cctor()
--- End of inner exception stack trace ---
at Microsoft.FSharp.Metadata.AssemblyLoader..cctor()
--- End of inner exception stack trace ---
at Microsoft.FSharp.Metadata.AssemblyLoader.Get(Assembly assembly)
at Microsoft.FSharp.Metadata.FSharpAssembly.FromAssembly(Assembly assembly)
at Program.main(String[] args) in
C:\Documents an...\FSMetadataTest\Program.fs:line 11
Press any key to continue . . .

最佳答案

Nathan,很好的调查,版本号在 2010 年 5 月的原始版本中确实没有更新,请参阅 http://fsharppowerpack.codeplex.com/workitem/4548我们已上传具有更正版本号的二进制文件。

关于F# Powerpack 的元数据无法将 FSharp.Core 识别为 F# 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2921880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com