SQLTeam.com | Weblogs | Forums

Error in SQL Server 2019 SMO

Has anyone done any work using SMO in SQL Server 2019? Using the downloadable SMO package?

I can't make it read a trace file. It always errors out with an Object not set to an instance of an object. And yes, I've installed the VC++ runtime from the README. I build a brand new machine and it still doesn't work.

# Add-Type -Path 'C:\Users\graz\source\repos\SmoTest\packages\Microsoft.SqlServer.SqlManagementObjects.150.18208.0\lib\net45\Microsoft.SqlServer.Smo.dll'

# SQL Server 2019 
Add-Type -Path 'C:\Users\graz\source\repos\SmoTest\packages\Microsoft.SqlServer.SqlManagementObjects.150.18208.0\lib\net45\Microsoft.SqlServer.ConnectionInfo.dll'
Add-Type -Path 'C:\Users\graz\source\repos\SmoTest\packages\Microsoft.SqlServer.SqlManagementObjects.150.18208.0\lib\net45\Microsoft.SqlServer.ConnectionInfoExtended.dll'

# Add-Type -Path 'C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\PFCLNT.DLL' 

#$sqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server -ArgumentList 'D40\SQL2019'
#$sqlServer.DomainInstanceName

$tf = New-Object Microsoft.SqlServer.Management.Trace.TraceFile
try {
    $tf.InitializeAsReader('C:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014\MSSQL\Log\log_30.trc')
    }
catch {
    $_ | select *
}

Hello,
After reading an info in a book, it seems that only nuget can help.

you must execute : nuget install Microsoft.SQLServer.SqlManagementObjects
then you get the Parser library. There no more Features pack since SQL Server 2017.
For me, i found another solution with using powershell integrated to the last SSMS version.

Thanks

What was your other solution?