问题描述
这是我的测试代码,用于找出问题所在:
Here's my test code to isolate the problem:
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#程序集(详细信息,请重新格式化以提高可读性).另外两个线索:
All three let
s should give me the same FSharpAssembly. Instead, all 3 throw an exception that FSharp.Core is not an F# assembly (details below, re-formatted for readability). Two more clues:
- 使用
core3
方法,对于测试F#程序集本身会得到相同的错误 - 执行
#r "@C:\Program Files...\FSharp.Powerpack.Metadata.dll"
后,我在FSI上未收到错误消息.
- Using the
core3
method, I get the same error for the test F# assembly itself - I don't get the error at FSI after doing
#r "@C:\Program Files...\FSharp.Powerpack.Metadata.dll"
.
有什么想法吗?我正在较旧的XP VM上使用Visual Studio 2008,F#2.0和F#Powerpack 2.0.0.0(2010年5月20日)发行,但我认为它已更新为SP3.
Any ideas? I'm using Visual Studio 2008, F# 2.0 and F# Powerpack 2.0.0.0 (May 20, 2010) release on an oldish XP VM, I think it's updated to SP3 though.
(今天早上我在使用Powerpack 1.9.9.9时遇到了错误,因此我升级到2.0.0.0.我认为,如果1.9.9.9无法识别F#的2.0.0.0的程序集,那么可能是在Powerpack 2.0中进行了错误修复. 0.0会有所帮助.)
(I got the error this morning with Powerpack 1.9.9.9, so I upgraded to 2.0.0.0. I thought that if 1.9.9.9 doesn't recognise F#'s 2.0.0.0's assemblies, then maybe bugfixes in Powerpack 2.0.0.0 would help.)
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月的原始发行版中并未更新,请参见workitem/4548"rel =" nofollow noreferrer> http://fsharppowerpack.codeplex.com/workitem/4548 我们已上传具有正确版本号的二进制文件.
Nathan, great investigation, the version number was indeed not updated in original May2010 release, see http://fsharppowerpack.codeplex.com/workitem/4548We have uploaded binaries with corrected version number.
这篇关于F#Powerpack的元数据无法将FSharp.Core识别为F#库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!