PowerDataOps icon indicating copy to clipboard operation
PowerDataOps copied to clipboard

Failed instantiating XrmClient

Open parvezghumra opened this issue 4 months ago • 4 comments

Hi @AymericM78,

I'm trying your module for the first time, specifically version 2.0.010, running on PowerShell 5.1.

The New-XrmClient cmdlet fails with an OAuth connection string if I pass in a username and password in the format AuthType=OAuth;Url=$serverURL;Username=$username;Password=$password

The same credentials work fine with Connect-CrmOnline using the Microsoft.Xrm.Data.PowerShell module.

Did you have any thoughts on this?

Thanks

parvezghumra avatar Oct 06 '25 17:10 parvezghumra

I have just retested with ClientSecret authentication and I get the same error. The error is as follows:

Exception calling ".ctor" with "1" argument(s): "Method not found: 'Microsoft.Extensions.Options.OptionsBuilder`1<!!0> Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions.AddOptions(Microsoft.Extensions.DependencyInjection.IServiceCollection)'."

parvezghumra avatar Oct 06 '25 17:10 parvezghumra

Hello @parvezghumra

I did the same on my side and it's OK. This error seems to be related to a bad .NET SDK version on your computer which can corrupt assembly loading. Can you share $PSVersionTable command result please? And can you try this on VS Code or Powershell ISE ?

Thanks

AymericM78 avatar Oct 07 '25 08:10 AymericM78

@AymericM78 I'm already running my script in VS Code. Here's the output of $PSVersionTable

Name Value PSVersion 5.1.26100.6725 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.26100.6725 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

parvezghumra avatar Oct 07 '25 09:10 parvezghumra

OK, this seems to be good.

Can you try outside VsCode please ? I faced an issue recently where VSCode extensions load different .NET dll in memory and corrupt CrmSdk load.

Thanks

AymericM78 avatar Oct 07 '25 13:10 AymericM78