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

C# 无法加载文件或程序集';Microsoft.Azure.Graphs';,c#,azure,azure-cosmosdb,C#,Azure,Azure Cosmosdb,我已经创建了一个Azure函数来连接CosmosDB图。我正在使用nuget软件包Microsoft.Azure.Graph 0.3.0-preview,当我到达函数的端点时,收到了错误 执行函数时出现异常:GetTrain->无法加载文件或程序集“Microsoft.Azure.Graphs,版本=0.3.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。系统找不到指定的文件。 下面是函数的代码,但它甚至没有达到这个程度 [FunctionN

我已经创建了一个Azure函数来连接CosmosDB图。我正在使用nuget软件包Microsoft.Azure.Graph 0.3.0-preview,当我到达函数的端点时,收到了错误

执行函数时出现异常:GetTrain->无法加载文件或程序集“Microsoft.Azure.Graphs,版本=0.3.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。系统找不到指定的文件。

下面是函数的代码,但它甚至没有达到这个程度

[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");
}
[FunctionName(“GetThing”)]
公共静态异步任务运行([HttpTrigger(AuthorizationLevel.Function,“get”,Route=“thing/{id}”)]HttpRequestMessage请求,字符串id,TraceWriter日志)
{
Info(“C#HTTP触发器函数处理了一个请求。”);
字符串端点=ConfigurationManager.AppSettings[“端点”];
字符串authKey=ConfigurationManager.AppSettings[“authKey”];
string db=ConfigurationManager.AppSettings[“db”];
字符串集合=ConfigurationManager.AppSettings[“集合”];
DocumentClient客户端=新DocumentClient(新Uri(端点)、authKey、,
新的连接策略{ConnectionMode=ConnectionMode.Direct,ConnectionProtocol=Protocol.Tcp});
DocumentCollection graph=await client.CreateDocumentCollectionIfNotexistsAsSync(
CreateDatabaseUri(db),
新文档集合{Id=collection},
新请求选项{OfferThroughput=1000});
IDocumentQuery query=client.CreateGremlinQuery(图,$”g.V('{id}')。has('thing');
//从请求URL中的path参数获取名称
返回req.CreateResponse(HttpStatusCode.OK,“Hello”);
}
更新 似乎有一个构建警告,完全没有看到。有什么想法吗

警告MSB3270正在生成的项目的处理器体系结构“MSIL”与参考“C:\Users\blah.nuget\packages\microsoft.azure.graphs\0.3.0-preview\lib\net461\microsoft.azure.graphs.dll”、“AMD64”的处理器体系结构不匹配。这种不匹配可能会导致运行时失败。请考虑通过配置管理器更改项目的目标处理器架构,以便在项目和引用之间对齐处理器体系结构,或者依赖于与您的项目的目标处理器体系结构相匹配的处理器体系结构的引用。


请尝试Microsoft.Azure.Graphs包的0.2.4预览版本。0.3.0版本似乎存在问题。请参阅SDK页面上的最新评论:

我还添加了一个GitHub问题:


github上的此问题解决了我的所有问题,只需将任何Cpu更改为x64

此问题针对软件包>=
0.3.1-preview
解决


正如其他人指出的,问题在于Microsoft.Azure.Graphs以前只针对x64平台。程序集的新版本现在是针对AnyCPU(MSIL)编译的。

我也可以在我这边复制它,我们可以给azure功能团队提供编译时警告。您有任何编译时警告吗?是的,更新了警告。我降级了我的包,开始比以前工作得更好,现在我只需要编写更好的查询!