![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Assembly loading error If i execute follwing code within a script test.ps1 i got following error.: New-Object : Cannot find type [Microsoft.SqlServer.Management.Common.ServerConnection]: make sure the assembly containing this type is loaded. But this happens just for the first execution of this script. Each other try in the same powershell window there is no error. Thanks for any help Michael R. Code: --------------------------------------------------------------------------------------------- [System.Reflection.Assembly]::LoadFile("C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies\Microsoft.SqlServer.Smo.dll") $smoServerConnection = New-Object Microsoft.SqlServer.Management.Common.ServerConnection; $smoServerConnection.ServerInstance = 'serverName'; $smoServerConnection.LoginSecure = $false; $smoServerConnection.Login = 'xxx'; $smoServerConnection.Password = 'xxx'; $serverConnection = New-Object Microsoft.SqlServer.Management.Smo.Server($smoServerConnection); --------------------------------------------------------------------------------------------- |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Assembly loading error Try to load it using PartialName: [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > If i execute follwing code within a script test.ps1 i got following > error.: > > New-Object : Cannot find type > [Microsoft.SqlServer.Management.Common.ServerConnection]: make sure > the assembly containing this type is loaded. > > But this happens just for the first execution of this script. Each > other try in the same powershell window there is no error. > > Thanks for any help > Michael R. > Code: > ---------------------------------------------------------------------- > ----------------------- > [System.Reflection.Assembly]::LoadFile("C:\Program Files\Microsoft SQL > Server\90\SDK\Assemblies\Microsoft.SqlServer.Smo.dll") > > $smoServerConnection = New-Object > Microsoft.SqlServer.Management.Common.ServerConnection; > > $smoServerConnection.ServerInstance = 'serverName'; > $smoServerConnection.LoginSecure = $false; $smoServerConnection.Login > = 'xxx'; $smoServerConnection.Password = 'xxx'; > > $serverConnection = New-Object > Microsoft.SqlServer.Management.Smo.Server($smoServerConnection); > ---------------------------------------------------------------------- > ----------------------- > |
My System Specs![]() |
| | #3 (permalink) |
| | RE: Assembly loading error I use $null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") $null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") $null = [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") in scripts and do not see any issues -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "Michael R." wrote: Quote: > If i execute follwing code within a script test.ps1 i got following error.: > > New-Object : Cannot find type > [Microsoft.SqlServer.Management.Common.ServerConnection]: make sure the > assembly containing this type is loaded. > > But this happens just for the first execution of this script. Each other try > in the same powershell window there is no error. > > Thanks for any help > Michael R. > > > Code: > --------------------------------------------------------------------------------------------- > [System.Reflection.Assembly]::LoadFile("C:\Program Files\Microsoft SQL > Server\90\SDK\Assemblies\Microsoft.SqlServer.Smo.dll") > > > $smoServerConnection = New-Object > Microsoft.SqlServer.Management.Common.ServerConnection; > > $smoServerConnection.ServerInstance = 'serverName'; > $smoServerConnection.LoginSecure = $false; > $smoServerConnection.Login = 'xxx'; > $smoServerConnection.Password = 'xxx'; > > $serverConnection = New-Object > Microsoft.SqlServer.Management.Smo.Server($smoServerConnection); > --------------------------------------------------------------------------------------------- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Loading .net assembly from VB6 code call | .NET General | |||
| Manual assembly loading necessary? | PowerShell | |||
| Problem loading an assembly referencing a non-.NET dll | PowerShell | |||
| Loading assembly dependencies with Powershell | PowerShell | |||
| Loading 3rd party .NET assembly | PowerShell | |||