Duplicate MEF export definitions in F #

I have this relatively simple program:

open System
open System.ComponentModel.Composition
open System.ComponentModel.Composition.Hosting
open System.Reflection

module Config =
    [<Export("Timer.Delay")>]
    let Delay = TimeSpan.FromSeconds(5.0)

[<EntryPoint>]
let main argv = 
    let catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly())
    let container = new CompositionContainer(catalog)
    let delay = container.GetExportedValue<TimeSpan> "Timer.Delay"

    printfn "Delay: %A" delay

But I get this error when called container.GetExportedValue<TimeSpan> "Timer.Delay":

More than one export was found that matches the limit:

& EPRS; ContractName & EPRS; & EPRS; & EPRS; & EPRS; & thinsp; Timer.delay

& EPRS; RequiredTypeIdentity & EPRS; System.TimeSpan

Checking the collection catalog.Parts, I see two parts, each with one ExportDefinition. The first one for Program+Configwhich I would expect to find, and one for <StartupCode$Remote>.$Program(note the assembly name Remote):

catalog.Parts

main module Program . - , F # ? ?

+4
1

, , , . , F # , , : . , , ExportAttribute . , , .

Program+Config:

module Config =
    [<property: Export("Timer.Delay")>]
    let Delay = TimeSpan.FromSeconds(5.0)

<StartupCode$Remote>.$Program:

module Config =
    [<field: Export("Timer.Delay")>]
    let Delay = TimeSpan.FromSeconds(5.0)

, , Export , .

+2

Source: https://habr.com/ru/post/1539646/


All Articles