Azure Functions DocumentClient无法从程序集异常加载类型 [英] Azure Functions DocumentClient could not load type from assembly exception

查看:63
本文介绍了Azure Functions DocumentClient无法从程序集异常加载类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个调用了实用程序库的Azure Function v2,该实用程序库又实例化了DocumentClient.在本地运行我的函数时,它将在此行上引发异常:

I have an Azure Function v2 that calls into an utility library, which in turn instantiates a DocumentClient. When running my function locally, it throws an exception on this line:

_client = new DocumentClient(new Uri(cosmosDbEndpoint), cosmosDbAuthKey, Storage.SerializerSettings, connectionPolicy);

System.Private.CoreLib:执行函数ComponentDesignInserter-Http-UploadFiles时发生异常. Microsoft.Azure.Documents.Client:无法从程序集"System.Core,版本= 4.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089"中加载类型"System.Diagnostics.Eventing.EventProviderTraceListener".

System.Private.CoreLib: Exception while executing function: ComponentDesignInserter-Http-UploadFiles. Microsoft.Azure.Documents.Client: Could not load type 'System.Diagnostics.Eventing.EventProviderTraceListener' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

我的实用程序库是.NET Framework 4.7.我的Azure Function v2项目是.NET Standard 2.0.那有问题吗?

My utility library is .NET Framework 4.7. My Azure Function v2 project is .NET Standard 2.0. Is that a problem?

还是我需要在Azure Function v2项目中安装某些依赖项的症状?实用程序库具有依赖项,但Azure Function v2项目没有该依赖项吗?

Or is this symptomatic of some dependency that I need to install in the Azure Function v2 project? A dependency that the utility library has but the Azure Function v2 project doesn't?

推荐答案

您提到的问题是,您正在使用NET Standard 2.0项目中的NET Framework 4.7库.

As you mention, the problem is that you are using a NET Framework 4.7 library from a NET Standard 2.0 project.

确保在NET 4.7库中使用的是Cosmos DB Core SDK:

Make sure that in your NET 4.7 library, you are using the Cosmos DB Core SDK: https://www.nuget.org/packages/Microsoft.Azure.DocumentDB.Core/

不是NET完整框架程序包( https://www.nuget.org/packages/Microsoft.Azure.DocumentDB ).

Not the NET Full Framework package (https://www.nuget.org/packages/Microsoft.Azure.DocumentDB).

在您的Azure Functions V2项目中,您还需要使用相同的nuget(核心).如果您使用的是 Microsoft.Azure.WebJobs.Extensions.CosmosDB 程序包,它已经包含在内.

In your Azure Functions V2 project, you also need to use the same nuget (Core). If you are using the Microsoft.Azure.WebJobs.Extensions.CosmosDB package, it is already included.

这篇关于Azure Functions DocumentClient无法从程序集异常加载类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆