microsoft / SQLServerPSModule

This repo is the home of SQL Server PowerShell Module development.
MIT License
45 stars 1 forks source link

Write-SqlTableData gets TypeInitializationException with 22.1.1 #58

Closed KenRokos closed 4 days ago

KenRokos commented 10 months ago

I upgraded from 21.1.18256 to 22.1.1, and now Write-SqlTableData gets an error.

Write-SqlTableData : The type initializer for 'Microsoft.Data.SqlClient.InOutOfProcHelper' threw an exception.
At line:1 char:1
+ Write-SqlTableData @SQLServerArguments -TableName 'OperatorLogins' -I ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-SqlTableData], TypeInitializationException
    + FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.SqlServer.Management.PowerShell.WriteSqlTableData

I also added -TrustServerCertificate to the command, but it fails the same way with or without that.

KenRokos commented 10 months ago

PowerShell version is 5.1.14393.5582. Running on Windows Server 2016 Standard. SQL Server is 2012, 11.0.7507 (SP4).

Matteo-T commented 6 months ago

Hi @KenRokos - could you provide full(er) repro? What you have above is not enought to even guess.

Maybe when you run into this, capture $Error[0].Exception.ToString() and see if there's anything useful?

Matteo-T commented 4 days ago

Closing due to lack of activity. Make sure you have .Net4.7.2+ on Windows Server 2016, in case you see this error: it may help for sure...