C# 交换服务没有';不能在Azure函数中工作
这是我初始化Exchange服务的代码C# 交换服务没有';不能在Azure函数中工作,c#,azure,outlook,azure-functions,exchange-server,C#,Azure,Outlook,Azure Functions,Exchange Server,这是我初始化Exchange服务的代码 ServicePointManager.ServerCertificateValidationCallback = delegate ( object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors ) {
ServicePointManager.ServerCertificateValidationCallback =
delegate (
object s,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors
) {
return true;
};
//Instantiate a new ExchangeService object
var exchangeService = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
//Set the exchange WebService URL
exchangeService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
//Set the credentials of the service to the credentials
//that are associated with the impersonating account.
exchangeService.Credentials = new NetworkCredential(userId, password);
它在我的本地系统上运行得非常好,我可以使用它创建约会。
但是,在将上述代码移动到Azure函数中后,它在初始化Exchange服务时返回以下错误
ServicePointManager.ServerCertificateValidationCallback =
delegate (
object s,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors
) {
return true;
};
//Instantiate a new ExchangeService object
var exchangeService = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
//Set the exchange WebService URL
exchangeService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
//Set the credentials of the service to the credentials
//that are associated with the impersonating account.
exchangeService.Credentials = new NetworkCredential(userId, password);
错误:
System.TypeInitializationException:“Microsoft.Exchange.WebServices.Data.ExchangeServiceBase”的类型初始值设定项引发错误
例外。-->System.ArgumentException:路径为空。
参数名称:路径
在System.IO.Path.GetFullPath(字符串路径)处
位于System.Diagnostics.FileVersionInfo.GetVersionInfo(字符串文件名)
在Microsoft.Exchange.WebServices.Data.EwsUtilities.b_uu9()上
在Microsoft.Exchange.WebServices.Data.LazyMember`1.get_Member()上
在Microsoft.Exchange.WebServices.Data.EwsUtilities.get_BuildVersion()上
在Microsoft.Exchange.WebServices.Data.ExchangeServiceBase..cctor()上
---内部异常堆栈跟踪的结束---
在Microsoft.Exchange.WebServices.Data.ExchangeServiceBase..ctor(TimeZoneInfo
时区)
在Microsoft.Exchange.WebServices.Data.ExchangeService..ctor()上
提交时,d:\home\site\wwwroot中的#0.d_u1.MoveNext()\
2020-01-27T10:55:35.631[信息]异常=======================:的类型初始值设定项
“Microsoft.Exchange.WebServices.Data.ExchangeServiceBase”引发异常
Azure功能还需要什么吗?根据您的问题,我还有很多其他问题,例如:您确定Exchange版本吗?您是否指定了正确的用户名和密码?而且,也许最重要的是:为什么不使用?在本地,它使用的是“Exchange2013\u SP1”版本以及用户名和密码。所以我确信这一点。使用Microsoft Graph和Azure广告,我们需要登录到我们的帐户。这种方式不适合我的项目和概念。希望您能提供帮助谢谢基于您的问题,我还有很多其他问题,例如:您确定Exchange版本吗?您是否指定了正确的用户名和密码?而且,也许最重要的是:为什么不使用?在本地,它使用的是“Exchange2013\u SP1”版本以及用户名和密码。所以我确信这一点。使用Microsoft Graph和Azure广告,我们需要登录到我们的帐户。这种方式不适合我的项目和概念。希望你能帮上忙谢谢