問題を特定するためのテストコードは次のとおりです。
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
3つすべてlet
が同じFSharpAssemblyを提供するはずです。代わりに、3つすべてがFSharp.CoreがF#アセンブリではないという例外をスローします(詳細は以下、読みやすくするために再フォーマットされています)。さらに2つの手がかり:
- この
core3
メソッドを使用すると、テストF#アセンブリ自体にも同じエラーが発生します - を実行した後、FSIでエラーが発生しません
#r "@C:\Program Files...\FSharp.Powerpack.Metadata.dll"
。
何か案は?古いXPVMでVisualStudio2008、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のアセンブリを認識しない場合は、Powerpack2.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 . . .