Type provider calling another dll in F#

后端 未结 1 1583
旧巷少年郎
旧巷少年郎 2020-12-17 05:12

In the construction of the internal representation for a provided type, I call indirectly in the quotation for the internal representation of my type, another dll, whose co

相关标签:
1条回答
  • Your assembly may be loaded into the different binding context. When quotation is deserialized it may try to load the assembly to the one binding context and this attempt may fail even if assembly was already loaded to another context. As workaround in your type provider design time assembly you can add handler to the AssemblyResolve event and try to find target assembly in the list of already loaded assemblies.

        do System.AppDomain.CurrentDomain.add_AssemblyResolve(fun _ args ->
            let name = System.Reflection.AssemblyName(args.Name)
            let existingAssembly = 
                System.AppDomain.CurrentDomain.GetAssemblies()
                |> Seq.tryFind(fun a -> System.Reflection.AssemblyName.ReferenceMatchesDefinition(name, a.GetName()))
            match existingAssembly with
            | Some a -> a
            | None -> null
            )
    
    0 讨论(0)
提交回复
热议问题