简体   繁体   English

无法加载文件或程序集'Microsoft.Azure.Graphs'

[英]Could not load file or assembly 'Microsoft.Azure.Graphs'

I've created an Azure Function to connect to a CosmosDB Graph. 我创建了一个Azure函数来连接到CosmosDB Graph。 I'm using the nuget package Microsoft.Azure.Graph 0.3.0-preview and am getting the error when I hit the endpoint of the function. 我正在使用nuget包Microsoft.Azure.Graph 0.3.0-preview,当我点击该函数的端点时出现错误。

Exception while executing function: GetTrain -> Could not load file or assembly 'Microsoft.Azure.Graphs, Version=0.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

The code for the function is below, but it doesn't even get as far as that. 该函数的代码如下,但它甚至没有达到这个目的。

[FunctionName("GetThing")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = "thing/{id}")]HttpRequestMessage req, string id, TraceWriter log)
{
    log.Info("C# HTTP trigger function processed a request.");

    string endpoint = ConfigurationManager.AppSettings["endpoint"];
    string authKey = ConfigurationManager.AppSettings["authkey"];
    string db = ConfigurationManager.AppSettings["db"];
    string collection = ConfigurationManager.AppSettings["collection"];

    DocumentClient client = new DocumentClient(new Uri(endpoint), authKey,
        new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp });

    DocumentCollection graph = await client.CreateDocumentCollectionIfNotExistsAsync(
            UriFactory.CreateDatabaseUri(db),
            new DocumentCollection { Id = collection },
            new RequestOptions { OfferThroughput = 1000 });


        IDocumentQuery<dynamic> query = client.CreateGremlinQuery<dynamic>(graph, $"g.V('{id}').has('thing')");

    // Fetching the name from the path parameter in the request URL
    return req.CreateResponse(HttpStatusCode.OK, "Hello");
}

Update 更新

Seems there is a build warning, completely didn't see that. 似乎有一个构建警告,完全没有看到。 Any thoughts? 有什么想法吗?

Warning MSB3270 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\\Users\\blah.nuget\\packages\\microsoft.azure.graphs\\0.3.0-preview\\lib\\net461\\Microsoft.Azure.Graphs.dll", "AMD64". 警告MSB3270正在构建的项目的处理器体系结构“MSIL”与参考“C:\\ Users \\ blah.nuget \\ packages \\ microsoft.azure.graphs \\ 0.3.0-preview \\ lib”的处理器体系结构不匹配\\ net461 \\ Microsoft.Azure.Graphs.dll“,”AMD64“。 This mismatch may cause runtime failures. 这种不匹配可能会导致运行时故障。 Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. 请考虑通过Configuration Manager更改项目的目标处理器体系结构,以便在项目和引用之间调整处理器体系结构,或者依赖于具有与项目的目标处理器体系结构相匹配的处理器体系结构的引用。

This issue is resolve for packages Microsoft.Azure.Graphs >= 0.3.1-preview . 软件包Microsoft.Azure.Graphs > = 0.3.1-preview解决了此问题。

As others have pointed out, the issue was that Microsoft.Azure.Graphs was previously targeting x64 platform only. 正如其他人所指出的那样,问题在于Microsoft.Azure.Graphs以前只针对x64平台。 New versions of the assembly are now compiled targeting AnyCPU (MSIL). 现在,针对AnyCPU(MSIL)编译了新版本的程序集。

Try the 0.2.4-preview version of the Microsoft.Azure.Graphs package. 尝试使用Microsoft.Azure.Graphs软件包的0.2.4预览版。 There seems to be an issue with the 0.3.0 release. 0.3.0版本似乎存在问题。 See recent comments on the SDK page: 查看SDK页面上的最新评论:

https://docs.microsoft.com/en-us/azure/cosmos-db/graph-sdk-dotnet https://docs.microsoft.com/en-us/azure/cosmos-db/graph-sdk-dotnet

And I added a GitHub issue: 我添加了一个GitHub问题:

https://github.com/Azure/azure-documentdb-dotnet/issues/361 https://github.com/Azure/azure-documentdb-dotnet/issues/361

github上的这个问题修复了我的一切https://github.com/Azure/azure-documentdb-dotnet/issues/361只更改任何Cpu到x64

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集&#39;Microsoft.Azure.AppConfiguration.AzconfigClient - Could not Load file or assembly 'Microsoft.Azure.AppConfiguration.AzconfigClient 无法加载文件或程序集“Microsoft.Azure.Management.ServiceBus.Fluent” - Could not load file or assembly 'Microsoft.Azure.Management.ServiceBus.Fluent' 无法加载文件或程序集“ Microsoft.WindowsAzure.Storage” Azure函数 - Could not load file or assembly 'Microsoft.WindowsAzure.Storage' Azure Functions 无法加载文件或程序集“ Microsoft.Azure.Storage.Emulator.Controller” - Could not load file or assembly 'Microsoft.Azure.Storage.Emulator.Controller' 无法加载文件或程序集&#39;Microsoft.Azure.Documents.Client - Azure-Table-Api - Could not load file or assembly 'Microsoft.Azure.Documents.Client - Azure-Table-Api Azure应用服务:无法加载文件或程序集Microsoft.Azure.Mobile.Server - Azure App Service: Could not load file or assembly Microsoft.Azure.Mobile.Server 无法加载文件或程序集 Microsoft.CodeAnalysis - Could not load file or assembly Microsoft.CodeAnalysis 无法加载文件或程序集“Microsoft.ReportViewer” - Could not load file or assembly 'Microsoft.ReportViewer' 运行时错误:无法加载文件或程序集&#39;Microsoft.Owin,版本= 3.0.0.0…Azure移动服务 - Runtime error: Could not load file or assembly 'Microsoft.Owin, Version=3.0.0.0…Azure mobile services Azure批处理作业错误:无法加载文件或程序集&#39;Microsoft.Data.OData - Azure batch job error:Could not load file or assembly 'Microsoft.Data.OData
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM