在尝试使用类型提供程序时,我遇到了“无法加载文件或程序集......系统找不到指定的文件”的错误。在构建消费应用程序时出现错误,但在构建之前在Visual Studio中没有显示为“红色波浪线”。
我已经复制了我的TP,但问题发生在
我调用Microsoft.Azure.DocumentDB包,它又依赖于Newtonsoft.Json。无法找到Newtonsoft.Json包。我使用Paket来管理依赖关系并进行重定向。
完整的代码(包括所有paket文件)在此处的github上:https://github.com/stewart-r/AzureDocumentDbTypeProvider/tree/dependency-issue 我找到了一个类似的问题这个问题,但解决方案没有任何改变。
我的TP代码如下:
我已经复制了我的TP,但问题发生在
Database.listDbs
调用内部,我强烈怀疑问题不在下面的代码中,而是在如何打包依赖项方面。我调用Microsoft.Azure.DocumentDB包,它又依赖于Newtonsoft.Json。无法找到Newtonsoft.Json包。我使用Paket来管理依赖关系并进行重定向。
完整的代码(包括所有paket文件)在此处的github上:https://github.com/stewart-r/AzureDocumentDbTypeProvider/tree/dependency-issue 我找到了一个类似的问题这个问题,但解决方案没有任何改变。
我的TP代码如下:
namespace ProviderImplementation
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
open System.Reflection
open System
open Config
open Database
[<TypeProvider>]
type public DocumentDbTypeProvider(config: TypeProviderConfig) as this =
inherit TypeProviderForNamespaces()
let thisAssembly = Assembly.GetExecutingAssembly()
let docDbType = ProvidedTypeDefinition(thisAssembly,namespaceName,"DocumentDbTypeProvider", baseType = Some typeof<obj>)
let initFn (typeName : string) (args : obj []) =
let acProvidedType = ProvidedTypeDefinition(thisAssembly, namespaceName, typeName, baseType = Some typeof<obj>)
acProvidedType.AddMember(ProvidedConstructor(parameters = [], InvokeCode = (fun args -> <@@ null @@>)))
let getDbProperties () =
Database.listDbs (args.[0] :?> string) (args.[1]:?> string)
|> List.map(fun d -> new ProvidedProperty(d.Name, typeof<string>, IsStatic = true, GetterCode = (fun _ -> <@@ "Test db name" @@>)))
acProvidedType.AddMembers(getDbProperties())
acProvidedType
let parameters =
[ ProvidedStaticParameter("accountEndPointUri", typeof<string>, String.Empty)
ProvidedStaticParameter("accountKey", typeof<string>, String.Empty)]
do
docDbType.DefineStaticParameters(parameters,initFn)
this.AddNamespace(namespaceName,[docDbType])
[<TypeProviderAssembly>]
do ()