Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodiscover Error in Windows UWP app #46

Open
somasundarambk opened this issue Dec 12, 2019 · 1 comment
Open

Autodiscover Error in Windows UWP app #46

somasundarambk opened this issue Dec 12, 2019 · 1 comment

Comments

@somasundarambk
Copy link

Hello, The UWP package we own throws this exception (below).
The call to DnsNativeMethods.FreeDnsQueryResults(queryResultsPtr); is called without a try catch around it and this stops further processing of auto discovery.

 0x80131522 System.TypeLoadException: Unresolved P/Invoke method 'dnsapi.dll!DnsRecordListFree' from this method. Please look for this method in build warnings for more details. 

	 at Microsoft.Exchange.WebServices.Dns.DnsNativeMethods.DnsRecordListFree(IntPtr, DnsNativeMethods.FreeType) + 0x2d
	 at Microsoft.Exchange.WebServices.Dns.DnsNativeMethods.FreeDnsQueryResults(IntPtr) + 0x8
	 at Microsoft.Exchange.WebServices.Dns.DnsClient.DnsQuery[T](String, IPAddress) + 0x2c0
	 at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverDnsClient.FindBestMatchingSrvRecord(String) + 0x8d
	 at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverDnsClient.FindAutodiscoverHostFromSrv(String) + 0x24
	 at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetRedirectionUrlFromDnsSrvRecord(String) + 0x3a
	 at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetSettings[TGetSettingsResponseCollection, TSettingName](List`1, List`1, Nullable`1, AutodiscoverService.GetSettingsMethod`2, Func`1) + 0x381
	 at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(List`1, List`1) + 0xcb
	 at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetSoapUserSettings(String, List`1) + 0x12a
	 at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(String, UserSettingName[]) + 0x5a
	 at Microsoft.Exchange.WebServices.Data.ExchangeService.GetAutodiscoverUrl(String, ExchangeVersion, AutodiscoverRedirectionUrlValidationCallback) + 0x87
	 at Microsoft.Exchange.WebServices.Data.ExchangeService.AutodiscoverUrl(String, AutodiscoverRedirectionUrlValidationCallback) + 0x34
@blakepell
Copy link

blakepell commented Jan 22, 2020

So I recently ran into this also when moving from the full framework version to this version. The short of it was, I forked the original Microsoft repo and converted it to .NET Standard 2 (didn't take much time and there were few hiccups, just added a few NuGets and removed one System.Web using). In the end though I tried to make AutoDiscovery work and couldn't. I manually entered the URL (which you'll have to find, it will be unique to your environment possibly):

var service = new ExchangeService(ExchangeVersion.Exchange2013_SP1)
{
    Credentials = new WebCredentials(username, password, domain)
};

// To future me, when this URL breaks at some point because it will, it has to be 
// updated to whatever the URL is on the new server.  Try to see if AutoDiscovery is working 
// again and also check that ExchangeVersion is still correct.
service.Url = new Uri(exchangeUrl);
service.EnableScpLookup = false;
service.Timeout = (1000 * 60) * 5;  // 5 Minutes

Not ideal but sometimes you have to get stuff done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants