0

尝试了我发现的所有内容,并在 EWS 服务上使用 AutodiscoverUrl 调用不断收到此错误。

已尝试提供 webcredentials、networkcredentials 和没有。如果我自己设置 service.Url 属性,那么它可以工作。我可以访问 EWS 呼叫没问题。

这是错误时的调用堆栈。

A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException'     occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.Exchange.WebServices.Dns.DnsException' occurred in Microsoft.Exchange.WebServices.dll
A first chance exception of type 'Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException' occurred in Microsoft.Exchange.WebServices.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'Microsoft.Exchange.WebServices.Dns.DnsException' occurred in Microsoft.Exchange.WebServices.dll
A first chance exception of type 'Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException' occurred in Microsoft.Exchange.WebServices.dll


An unhandled exception of type 'Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException' occurred in Microsoft.Exchange.WebServices.dll

Additional information: The Autodiscover service couldn't be located.

我还检查了我可以通过 dns 条目自动发现 ping Exchange 服务器。我已经检查了 SCP 的广告,它看起来没问题。Outlook 可以发现自动发现没有问题。只有我的代码不能。

万一这很重要,我的所有机器都是虚拟子网上的 Azure vm。

我的代码:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.AutodiscoverUrl("Lyynx@ocean.lythixdesigns.com"); // Exception is thrown here
4

1 回答 1

1

在反编译和调试抛出的异常后,我发现由于使用了自签名证书,它不允许使用自动发现 url。

http://blogs.msdn.com/b/robert_mcmurray/archive/2013/11/15/how-to-trust-the-iis-express-self-signed-certificate.aspx

此 url 显示如何将证书复制到 Internet Explorer 中的受信任的根证书颁发机构文件夹中。我以管理员身份运行 IE 并将其复制进去。我的代码现在可以工作了。它又遇到了一个异常,说它没有经过身份验证,但我认为这就是它使用登录凭据的地方。

所以信任证书是我问题的答案。

于 2014-09-23T09:48:18.280 回答