我正在尝试在针对我的Azure CosmosDb的F#脚本文件中测试一些不同的查询,但是当我尝试执行查询本身时,我收到有关丢失的DLL的错误.
我正在加载Documents.Client.dll:
#r "../packages/Microsoft.Azure.DocumentDB/lib/net45/Microsoft.Azure.Documents.Client.dll"
open Microsoft.Azure.Documents
open Microsoft.Azure.Documents.Client
open Microsoft.Azure.Documents.Linq
Run Code Online (Sandbox Code Playgroud)
但是当我执行一个查询时:
Seq.toList <| query {
//some query that I copy & pasted from a working file
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
System.AggregateException: One or more errors occurred. ---> System.DllNotFoundException: Unable to load DLL 'Microsoft.Azure.Documents.ServiceInterop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Microsoft.Azure.Documents.ServiceInteropWrapper.CreateServiceProvider(String configJsonString, IntPtr& serviceProvider)
at Microsoft.Azure.Documents.Query.QueryPartitionProvider.Initialize()
at Microsoft.Azure.Documents.Query.QueryPartitionProvider.GetPartitionedQueryExecutionInfoInternal(SqlQuerySpec querySpec, PartitionKeyDefinition partitionKeyDefinition, Boolean requireFormattableOrderByQuery, Boolean isContinuationExpected)
at Microsoft.Azure.Documents.Query.DocumentQueryExecutionContextBase.<GetPartitionedQueryExecutionInfoAsync>d__0.MoveNext()
Run Code Online (Sandbox Code Playgroud)
(堆栈跟踪中有更多 - 这只是它的顶部).
我无法在ServiceInterop任何地方找到dll - 它没有在任何项目或我的包文件夹中引用,并且它不是nuget引用.我不确定在F#Interactive中只能得到这个错误.
更新
根据@ tomislav-markovski的评论中的建议,我将版本更改Microsoft.Azure.DocumentDB为1.13.2.这确实ServiceInterop在包文件夹中创建了dll,但现在在F#interactive中运行我的查询会给出以下输出:
--> Referenced 'c:\VSTS\MyApplication\../packages/Microsoft.Azure.DocumentDB/lib/net45/Microsoft.Azure.Documents.Client.dll' (file may be locked by F# Interactive process)
Script.fsx(5,1): error FS0229: Error opening binary file 'c:\VSTS\MyApplication\../packages/Microsoft.Azure.DocumentDb/runtimes/win7-x64/native/Microsoft.Azure.Documents.ServiceInterop.dll': c:\VSTS\MyApplication\../packages/Micro
soft.Azure.DocumentDb/runtimes/win7-x64/native/Microsoft.Azure.Documents.ServiceInterop.dll: bad cli header, rva 0
Script.fsx(5,1): error FS3160: Problem reading assembly 'c:\VSTS\MyApplication\../packages/Microsoft.Azure.DocumentDb/runtimes/win7-x64/native/Microsoft.Azure.Documents.ServiceInterop.dll': Exception of type 'Microsoft.FSharp.Compiler.ErrorLogger+
StopProcessingExn' was thrown.
Run Code Online (Sandbox Code Playgroud)
"文件可能被锁定"错误似乎很重要,但我关闭并重新打开VSCode以确保F#Interactive的实例没有保留任何内容.我正在引用Service Interop文件:
#r "../packages/Microsoft.Azure.DocumentDb/runtimes/win7-x64/native/Microsoft.Azure.Documents.ServiceInterop.dll"
如果我删除它,上面的错误就会消失......然后我会回到查询本身崩溃,因为缺少DLL.
更新2
我尝试了一些额外的东西:
Client.dll.这导致"缺少服务interop dll"错误.使用#I加载使用更方便寻路的DLL:
#I "../packages/Microsoft.Azure.DocumentDB/lib/net45/"
#r "Microsoft.Azure.Documents.Client.dll"
导致相同的"丢失ServiceInterop.dll"错误.
简化查询:
Seq.toList <| query {
for t in client.CreateDocumentQuery( documentCollectionUri()) do
select t
}
这导致了相同的"遗漏ServiceInterop.dll"错误.5.将FeedOptions与"启用交叉分区查询"一起使用:
let feedOptions = FeedOptions()
feedOptions.EnableCrossPartitionQuery <- true
feedOptions.MaxItemCount <- 3 |> System.Nullable
Seq.toList <| query {
for t in client.CreateDocumentQuery( documentCollectionUri(), feedOptions ) do
select t
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我也尝试设置最大项目数.这两个都给出了相同的"遗漏ServiceInterop.dll"错误.
我能找到的最接近解决方案的方法是在 FSI 会话期间将 ServiceInterop.dll 的位置添加到 Path 环境变量中,如下所示:
open System
open System.IO
// get existing contents of path env var
let path = Environment.GetEnvironmentVariable("Path")
// get location where nuget puts the service interop dll
let serviceInteropDir = @C:\User\<USERNAME>\.nuget\packages\microsoft.azure.documentdb.core\1.9.1\runtimes\win\native"
// add service interop location to the end of the path
let newPath = path + ";" + serviceInteropDir
// update the path env var with the new path
Environment.SetEnvironmentVariable("Path", newPath)
Run Code Online (Sandbox Code Playgroud)
注意:请注意,我使用的是 DocumentDB.Core 包的 1.9.1 版本。DocumentDB.Core 包的 1.10.0 版本似乎存在严重的命名问题,因此在发布修复程序或找到解决方法之前,请避免使用该版本。
| 归档时间: |
|
| 查看次数: |
292 次 |
| 最近记录: |