ItsClemi / ews-managed-api

https://www.nuget.org/packages/Exchange.WebServices.NETCore
Other
5 stars 1 forks source link

ArgumentOutOfRangeException in AutodiscoverService #18

Closed jensschmidbauer closed 3 months ago

jensschmidbauer commented 3 months ago

Hi, I'm just migrating from Microsoft.Exchange.WebServices.NETStandard to Exchange.WebServices.NETCore. Unfortunately, there's an Exception in AutoDiscoverService.PrepareHttpClient when setting the Timeout of the newly created HttpClient.

minimal code to reproduce (replace "***"):

const string server = "***";
const string mailAddress = "***";

AutodiscoverService service = new()
{
    Url = new Uri($"https://{server}/autodiscover/autodiscover.svc")
};

Console.WriteLine(service.Timeout); // 0

await service.GetUserSettings(mailAddress, UserSettingName.ExternalEwsUrl); // ArgumentOutOfRangeException

System.ArgumentOutOfRangeException: "value ('00:00:00') must be greater than '00:00:00'.

System.ArgumentOutOfRangeException.ThrowIfLessThanOrEqual[T](T value, T other, String paramName) System.ArgumentOutOfRangeException.ThrowLessEqual[T](T value, T other, String paramName) System.Net.Http.HttpClient.set_Timeout(TimeSpan value) Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.PrepareHttpClient() Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverRequest.d3.MoveNext() Microsoft.Exchange.WebServices.Autodiscover.GetUserSettingsRequest.d4.MoveNext() Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.d36.MoveNext() Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.d35`2.MoveNext() Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.d33.MoveNext() Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.d65.MoveNext()

Timeout always returns 0 (wenn set to full seconds).

ExchangeServiceBase.Timeout_get should return _httpClient.Timout.TotalMilliseconds (instead of .Milliseconds), and for that the property type has to be double.

Would be great if you could fix this. Thanks in advance.

ItsClemi commented 3 months ago

Hi, thanks for reporting this issue!

I've applied the changes you suggested in 2.1.2, but I kept the integer type on the property to preserve API compatibility (for now).

Thanks!