Powershell 7 with RDM modules returns an exception: The type initializer for 'Client.ConnectorFactory' threw an exception

Implemented

Powershell 7 with RDM modules returns an exception: The type initializer for 'Client.ConnectorFactory' threw an exception

avatar

We are trying to run some commands from a Server 2012R2 to our RDM.

We installed the RemoteDesktopModule

The RDM server is version 2021.2.29.0

We tried to install the module with 2022.3.1.2, with 2021.2.0.43 and 2021.2.0.29.

We installed it using the cmdlet from the PSGallery - Install-Module -Name RemoteDesktopManager -RequiredVersion 2021.2.0.29

However, when running ANY command, even Get-RDMInstance we receive always the same error:

Get-RDMInstance: Object reference not set to an instance of an object.

or

The type initializer for 'Client.ConnectorFactory' threw an exception.\n at Client.ConnectorFactory..ctor()

Tried multiple times to completely uninstall the module, cleaned all $env:PSModulePath folders from anything that resembles the Module, installed again, restarted the server, and got the same error at the end.

Is there any way to trace the source of the issue?

Thanks!

All Comments (14)

avatar

Attempting to install the module fresh returns this error.

However, when I run Get-Command (any of the commands) it says the command is not recognized

I can install the module only if I select -AllowClobber

avatar

Hello,

The latest version of the RDM module will not work with your version, you were on the right path by installing the older version. What version of PowerShell 7 are you using? With the older version of the module, 7.3 will most likely not work, you may have to use 7.2 or even 7.1.

Could you first uninstall the RDM module by using this cmdlet

Uninstall-Module -Name RemoteDesktopManager

Once uninstalled, close and reopen the PowerShell window and install the last release of the 2021.2 cycle:

Install-Module -Name RemoteDesktopManager -RequiredVersion 2021.2.0.43

Once this is done, you have to connect to the correct data source, assuming you have RDM installed on the machine:

$ds = Get-RDMDataSource -Name "NameOfYourDataSourceHere"
Set-RDMCurrentDataSource $ds
$ds

The last line should show the isConnected set to True. If so, you should be all set.

Finally, please note I moved your thread to the PowerShell support section of the forum.

Best regards,

Richard Boisvert

avatar

Hi,

Regarding type initializer for 'Client.ConnectorFactory' threw an exception, it is generally thrown when another PowerShell module is already loaded and interferes with ours. While initializing our module, we use reflection to check if a certain type is available from the libraries shipped with our module.

However, due to the way the power shell process works, we also pull in other modules referenced libraries while doing so and they can cause issues.

I'll see if there's a way we could improve the way we fetch our referenced libs to avoid this scenario or even switch to a different method altogether for our module.

Either way, would you be interested in testing a build with a potential fix?

Regards

Jonathan Lafontaine