grahamr975 / EWS-Office365-Contact-Sync

Uses Exchange Web Services to synchronize a Global Address List in Office 365 to a user's mailbox
MIT License
94 stars 21 forks source link

Cannot find an appropriate constructor for type Microsoft.Exchange.WebServices.Data.OAuthCredentials #97

Open BerryC opened 8 months ago

BerryC commented 8 months ago

Hello,

I get below error. Is there someone with a solution or can point me to the right direction?

2023-11-09 10:33:26 INFO All jobs complete: retrieving results... PS>TerminatingError(): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: A constructor was not found. Cannot find an appropriate constructor for type Microsoft.Exchange.WebServices.Data.OAuthCredentials." 2023-11-09 10:33:26 ERROR Failed to Sync-ContactList for 1234@1234.nl A constructor was not found. Cannot find an appropriate constructor for type Microsoft.Exchange.WebServices.Data.OAuthCredentials.

BerryC

grahamr975 commented 4 months ago
  1. Did you unblock the .dll files mentioned in the tutorial?
  2. Did you set this setting in your Azure app? "Advanced settings -> Allow public client flows -> Enable the following mobile and desktop flows -> Yes"
mmuellenbach commented 4 months ago

I had the same issue, suddenly comming up. It looks like, that unblocking all ps1 Files in all directories fixed it for me. So you might want to give it a try as well.

CrepuscularSatori commented 3 months ago

Out the gate, I couldn't get passed this same error after trying a bunch of things, but then it occurred to me that I was running it from PowerShell Core (v7.4.1) instead of plain old Windows PowerShell (5.1.17763.5576 to be exact). Running it from Windows PowerShell, suddenly it worked like a charm.

BerryC commented 3 months ago

Thanks for all the options.

All files are unblock and still the same error under PSVersion 7.3.8.

Running under PSVersion 5.1.14393.6343 I get error below:

PS>TerminatingError(Get-ConnectionContext): "One or more errors occurred." PS>TerminatingError(): "Could not use the certificate for signing. See inner exception for details. Possible cause: this may be a known issue with apps build against .NET Desktop 4.6 or lower. Either target a higher version of .NET desktop - 4.6.1 and above, or use a different certificate type (non-CNG) or sign your own assertion as described at https://aka.ms/msal-net-signed-assertion. "

grahamr975 commented 2 months ago

@BerryC Per my understanding, I'm using the latest version of .NET Framework. I'd recommend upgrading to the latest version and try that.