none
Microsoft.SqlServer.Smo.dll

    Question

  • I create console using .net 2.0 platform and add reference to Microsoft.SqlServer.Smo.dll and friends. These assemblies taken from C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies folder. I check its runtime version is v2.0.50727, which is correct for my application.

    But When compile, they said can not find Microsoft.SqlServer.Smo.Server class. Then I change my project runtime version to 3.5 and it is works fine.

    Why this happen and how if I need my application to run on 2.0 ?


    It's hard to be advanced programmer

    Wednesday, May 23, 2012 12:55 PM

Answers

  • Then I guess, you are using an old release of SMO 2005; please install the last update from Feature Pack SP2; it's the first link Papy posted.

    And to show you, that it works, here a little sample app and my output of it; as you can see I am using SMO 9 = 2005 and I connect to SQL Server 10 = 2008 and it works:

    Imports Microsoft.SqlServer.Management.Smo
    
    Module Smo2005Test
    
        Sub Main()
    
            Dim server As New Server(".\SQLEXPRESS")
    
            Console.WriteLine(Reflection.Assembly.GetAssembly(GetType(Microsoft.SqlServer.Management.Smo.Server)).ImageRuntimeVersion)
            Console.WriteLine(Reflection.Assembly.GetAssembly(GetType(Microsoft.SqlServer.Management.Smo.Server)).CodeBase)
            Console.WriteLine(server.Information.VersionString)
    
            Console.ReadKey()
        End Sub
    
    End Module


    Olaf Helper
    * cogito ergo sum * errare humanum est * quote erat demonstrandum *
    Wenn ich denke, ist das ein Fehler und das beweise ich täglich
    Blog Xing

    • Proposed as answer by Papy NormandModerator Friday, May 25, 2012 9:37 AM
    • Marked as answer by IRW7 Wednesday, May 30, 2012 2:39 AM
    Friday, May 25, 2012 9:34 AM

All replies

  • I check its runtime version is v2.0.50727

    ...

    Why this happen and how if I need my application to run on 2.0 ?

    Hello,

    That's the CLR version, not the .NET version of the assembly; see http://msdn.microsoft.com/en-us/library/bb822049.aspx

    SMO for SQL Server 2008 (=100) is a .NET 3.5 assembly. If you need SMO as a .NET 2.0 assembly, then you have to use SMO of SQL Server 2005, you can get it from the SQL Server 2005 Feature Pack; it should be still available.


    Olaf Helper
    * cogito ergo sum * errare humanum est * quote erat demonstrandum *
    Wenn ich denke, ist das ein Fehler und das beweise ich täglich
    Blog Xing

    Wednesday, May 23, 2012 2:03 PM
  • I see, you right. This SMO 2005 is failed to connect to sql server 2008.

    Is SMO 2005 limited to connect to version 2005 and below only ? 

    To connect to sql server 2008, then I need to using SMO 2008 and .net framework 3.5 ?


    It's hard to be advanced programmer

    Thursday, May 24, 2012 2:07 AM
  • Hello,

    Just a little add-in to the excellent post from Olaf.

    The SQL Server 2005 Feature pack is available here  ( for SQL Server 2005 SP2 ):

    http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=24793

    x86 SMO : http://download.microsoft.com/download/2/7/c/27c60d49-6dbe-423e-9a9e-1c873f269484/SQLServer2005_XMO.msi

    i64 SMO  : http://download.microsoft.com/download/2/7/c/27c60d49-6dbe-423e-9a9e-1c873f269484/SQLServer2005_XMO_x64.msi

    The last version ( corresponding to SQL Server 2005 SP4 ) is :

    http://www.microsoft.com/en-us/download/details.aspx?id=20101

    SMO 2005 can be used versus a SQL Server 2008 but you cannot use the new features specific to SQL Server 2008 ( for example everything coming from the Microsoft.Management.Smo with CompatibilityLevel

    http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.compatibilitylevel(SQL.100).aspx

    Version100 will not exist ( except thru an Int32 value )

    Idem for FileStream or datetime2.

    To connect to SQL Server 2008 with SMO 2005 is possible but you cannot manage features specific to SQL Server 2008 or 2008 R2.

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    Thursday, May 24, 2012 6:38 AM
  • This SMO 2005 is failed to connect to sql server 2008.

    Good morgning,

    Which error message do you get?

    As Papy already wrote, you can use SMO 2005 to connect to and manage SQL Server 2008/2008R2, only the new feature are not available. You can simply test it; SSMS use SMO as well and with SSMS 2005 you can manage SQL Server 2008.


    Olaf Helper
    * cogito ergo sum * errare humanum est * quote erat demonstrandum *
    Wenn ich denke, ist das ein Fehler und das beweise ich täglich
    Blog Xing

    Thursday, May 24, 2012 7:00 AM
  • This is the message :

    {"This SQL Server version (10.0) is not supported."}

    Source : Microsoft.SqlServer.ConnectionInfo

    Stack Trace :

       at Microsoft.SqlServer.Management.Common.ConnectionManager.CheckServerVersion(ServerVersion version)
       at Microsoft.SqlServer.Management.Common.ConnectionManager.InternalConnect(WindowsIdentity impersonatedIdentity)
       at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()


    It's hard to be advanced programmer

    Friday, May 25, 2012 9:06 AM
  • Then I guess, you are using an old release of SMO 2005; please install the last update from Feature Pack SP2; it's the first link Papy posted.

    And to show you, that it works, here a little sample app and my output of it; as you can see I am using SMO 9 = 2005 and I connect to SQL Server 10 = 2008 and it works:

    Imports Microsoft.SqlServer.Management.Smo
    
    Module Smo2005Test
    
        Sub Main()
    
            Dim server As New Server(".\SQLEXPRESS")
    
            Console.WriteLine(Reflection.Assembly.GetAssembly(GetType(Microsoft.SqlServer.Management.Smo.Server)).ImageRuntimeVersion)
            Console.WriteLine(Reflection.Assembly.GetAssembly(GetType(Microsoft.SqlServer.Management.Smo.Server)).CodeBase)
            Console.WriteLine(server.Information.VersionString)
    
            Console.ReadKey()
        End Sub
    
    End Module


    Olaf Helper
    * cogito ergo sum * errare humanum est * quote erat demonstrandum *
    Wenn ich denke, ist das ein Fehler und das beweise ich täglich
    Blog Xing

    • Proposed as answer by Papy NormandModerator Friday, May 25, 2012 9:37 AM
    • Marked as answer by IRW7 Wednesday, May 30, 2012 2:39 AM
    Friday, May 25, 2012 9:34 AM


  • Hello,

    I have already changed in App.Config file like this

    <?xml version="1.0"?>
    <configuration>
      <startup useLegacyV2RuntimeActivationPolicy="true">

        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
      </startup>
    </configuration>
    and target framework also changed.But i got a exception while i was execute the database script with ExecuteNonQuery method.

    "system io fileloadexception mixed mode is built against version 2.0 "

    Any Idea about the problem?

    Thanks in advance.
    Monday, March 10, 2014 12:33 PM