【问题标题】:The Autodiscover service couldn't be located in C# but works for Outlook自动发现服务无法位于 C# 中,但适用于 Outlook
【发布时间】:2014-09-23 17:48:18
【问题描述】:

尝试了我发现的所有内容,并在 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

【问题讨论】:

  • 您可以尝试的两件事是首先启用跟踪,这将提供更多信息,然后是堆栈跟踪。另一件事是使用 testconnectivity.microsoft.com 测试您的自动发现配置
  • 我启用了跟踪,它甚至不调用跟踪器。我通过使用工作代码跟踪它来验证跟踪器是否正常工作。我查看了您共享的测试页面,但我需要弄清楚如何让它在 Internet 上运行,对吗?还是该页面在 Intranet 上工作?会再看一遍
  • 不,这在 Intranet 上不起作用,您必须将自动发现暴露在外部,这对于大多数人来说通常是这种情况(否则 Activesync 等将不起作用)。另一个测试是尝试ewseditor.codeplex.com,这将允许您在代码之外测试托管 API 和 EWS。
  • 方便的工具。我下载了它并在我的开发虚拟机上运行。 InternalEwsUrl:mantaray.ocean.lythixdesigns.com/EWS/Exchange.asmx 这是我输入的有效网址。
  • 您尝试过自动发现查看器吗? (从“工具”菜单中)这将向您显示自动发现过程的更多调试版本

标签: exchangewebservices exchange-server-2013


【解决方案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 并将其复制进去。我的代码现在可以工作了。它又遇到了一个异常,说它没有经过身份验证,但我认为这就是它使用登录凭据的地方。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-26
    • 1970-01-01
    • 2013-03-30
    • 2012-10-05
    • 2020-02-19
    • 1970-01-01
    • 2016-05-18
    • 1970-01-01
    相关资源
    最近更新 更多