Could not load file or assembly Microsoft.SqlServer.Smo, Version=9.0.242.0

  • Hi all
    A lot happened on my machine at work last week - I installed Visual Studio 2015 which somehow messed up my SQL 2016 install. So I uninstalled SQL 2016 (and too the opportunity to clear out other older versions of SQL lying around as I inherited this PC from someone else). I then installed SQL 2017 (management studio and engine). Now for some reason the PowerShell script I use for SQL Daily Checks is failing, with:

    Could not load file or assembly Microsoft.SqlServer.Smo, Version=9.0.242.0...

    Did some research and discovered (through running the following command) that I don't have any SMO objects installed : [System.appdomain]::CurrentDomain.GetAssemblies() | Select location

    So i've been trying to figure out how to get these components installed (for SQL 2017), and all I can find is this: 
    https://docs.microsoft.com/en-us/sql/relational-databases/server-management-objects-smo/installing-smo?view=sql-server-2017Nu get?? First I've ever heard of it!

    Can someone please shed some light on this for me? Feels like this is all more complicated than it needs to be...

    Thanks in advance!
    Doodles

  • doodlingdba - Tuesday, April 17, 2018 5:36 AM

    Hi all
    A lot happened on my machine at work last week - I installed Visual Studio 2015 which somehow messed up my SQL 2016 install. So I uninstalled SQL 2016 (and too the opportunity to clear out other older versions of SQL lying around as I inherited this PC from someone else). I then installed SQL 2017 (management studio and engine). Now for some reason the PowerShell script I use for SQL Daily Checks is failing, with:

    Could not load file or assembly Microsoft.SqlServer.Smo, Version=9.0.242.0...

    Did some research and discovered (through running the following command) that I don't have any SMO objects installed : [System.appdomain]::CurrentDomain.GetAssemblies() | Select location

    So i've been trying to figure out how to get these components installed (for SQL 2017), and all I can find is this: 
    https://docs.microsoft.com/en-us/sql/relational-databases/server-management-objects-smo/installing-smo?view=sql-server-2017Nu get?? First I've ever heard of it!

    Can someone please shed some light on this for me? Feels like this is all more complicated than it needs to be...

    Thanks in advance!
    Doodles

    NuGet is just a package manager for Microsoft's platforms. For SQL Server, they used to have the feature pack. SMO was with the feature packs in the past. The equivalent pieces you download from NuGet. In your case, it's just downloading one of the things that was with the feature pack.

    Sue

  • Thanks for responding Sue... doesn't feel simple though. I can't just download the SMO package - i know need some sort of nuget client to help me install the package, and it isn't straight forward what client i need. It's really frustrating, or what commands to use....

  • Try


    install-packageprovider NuGet -Force

    get-packagesource

    Install-Package Microsoft.SqlServer.SqlManagementObjects -source https://www.nuget.org/api/v2

    The source in the last line should be listed as a location in the output of get-packagesource

  • SQLPirate - I'm so confused - where am i running these commands from? PowerShell ise?? I have downloaded and installed (i think) Nuget.exe (from here: https://www.nuget.org/downloads)
    What does that actually do? I cannot find an app on my machine called Nuget so not sure what the install has done.
    Could someone please spell out the exact steps i need to do (in detailed form, as i am just not getting it) in order to download the SMo objects onto my machine so I can start running my PowerShell scripts again.

    Thanks!

  • OK - well i've discovered there is a much easier way to install the SMO objects without having to use NuGet! You install it from the PS Gallery! In PS, type the following:

    Install-Package sql-smo

    Was hard to find the info though - seems MS is trying to force us down the NuGet route! But from what i can see on Google, plenty of people are having issues with this method....

    Hopefully this will be useful for someone.

    Doodles

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply