Digite provedor chamando outra dll em F #
Na construção da representação interna para um tipo fornecido, eu chamo indiretamente na cotação para a representação interna do meu tipo, outra dll, cujo código eu possa modificar.
Atualmente, quando eu consome o provedor de tipo, me diz que não pode encontrar tal dll:
"Não foi possível carregar o arquivo ou a Assembly xxxx ou uma de suas dependências"
Quando eu inspecionar o VS usando o Process Explorer, no entanto, eu posso ver a dll XXX carregada ... Há alguma coisa a fazer para que o código entre aspas aceite o código de fora da dll?
** update **
Eu tentei com um exemplo simplificado, e parece que é possível chamar tal dll externa sem qualquer coisa especial para fazer. No meu caso, todos os dll XXX depende são carregados, vejo-os no Process explorer, bem como nas janelas de módulos quando eu depurar devenv.exe em si ....
Não tenho a menor ideia para onde procurar. Aqui está a exceção interna.
** update **
Se eu copiar a dll xxx e suas dependências em um desse caminho, o compilador funciona bem. Eu ainda me pergunto o que pode desencadear devenv.exe para mostrá-los corretamente carregado, mas não acessível.
=== Pre-bind state information ===
LOG: User = xxx\Administrator
LOG: DisplayName = bloombergapi, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Administrator\AppData\Local\Microsoft\VisualStudio\11.0\devenv.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/bloombergapi/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/PublicAssemblies/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/PublicAssemblies/bloombergapi/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/PrivateAssemblies/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/PrivateAssemblies/bloombergapi/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/bloombergapi/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Platform/Debugger/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Platform/Debugger/bloombergapi/bloombergapi.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/IDE/PrivateAssemblies/DataCollectors/bloombergapi.DLL.
...
RESPONDA
Parece impossível chamar uma função que tome como argumento um Type de outra biblioteca. Um tipo de união funciona, mas não um tipo apropriado ... Isso é ilustrado abaixo
--Library.dll
namespace Library
module SampleModule =
type LocalUnion = | LocalUnion of int
type Localtype() =
member x.value = 2
--LibraryTP.dll
namespace LibraryTP
module Module =
open System.Reflection
open Samples.FSharp.ProvidedTypes
open FSharpx.TypeProviders.DSL
open Microsoft.FSharp.Core.CompilerServices
let f a =
Library.SampleModule.sampleFunction a a
let g (a:Library.SampleModule.LocalUnion) =
let (Library.SampleModule.LocalUnion(v)) = a
v
let ftype (a:Library.SampleModule.Localtype) =
a.value
let createTP ns =
erasedType<obj> (Assembly.GetExecutingAssembly()) ns "Outside"
|> staticParameter "file"
(fun typeName (parameterValues:string) ->
erasedType<obj> (Assembly.GetExecutingAssembly()) ns typeName
|+!> ( provideProperty
"test" //OK
typeof<float>
(fun args -> <@@ g ( f 2 ) @@>)
|> makePropertyStatic
)
|+!> ( provideProperty
"test2" //KO
typeof<int>
(fun args -> <@@ ftype ( Library.SampleModule.Localtype()) @@>)
|> makePropertyStatic
)
)
[<TypeProvider>]
type public CustomTypeProvider(cfg:TypeProviderConfig) as this =
inherit TypeProviderForNamespaces()
do this.AddNamespace("TP", [createTP "TP"])
[<TypeProviderAssembly>]
do()
--Program.fs
type sampleValue = TP.Outside<"">
[<EntryPoint>]
let main(args) =
let t = sampleValue.Test //OK
let tt = sampleValue.Test2 //KO