Proposed Answer restoring DB using c# .Net 3.5 SP1

  • Wednesday, December 15, 2010 5:22 PM
     
     

    I building a simple utility to restore bak file into DB

     

    1.       I  Referenced Microsoft.SqlServer.Smo.dll v10 and trying to create a Server object.

    Compile error was: 'Microsoft.SqlServer.Management.Sdk.Sfc.ISfcPropertyProvider' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'

     

    2.       Although MSDN indicates not to reference this dll I added a reference to this assembly and now Server is created

     

    3.       Now I am trying to create Restore object – but this type could not be found in the Microsoft.SqlServer.Management.Smo namespace

     

    4.       Referencing version 9.0.242.0 of Microsoft.SqlServer.Smo.dll (which was not in the VS2008 assembly list and could be referenced only by manually edit the project file) solved all compilation errors

     

    5.       I am using a VS 2008 SP1 on a machine but the target framework of the project  is .NET Framework 2.0. No SQL server installed on the development machine.

     

     

    6.       After compiling I deployed it (simply copied the exe) to a machine with SQLexpress DB and .NET 2.0. Running the program caused an error: Could not load file or assembly 'Microsoft.SqlServer.SqlClrProvider, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

     

    7.       What am I missing?

     

    Tx

     

    Oren

     

All Replies

  • Thursday, December 16, 2010 9:52 AM
     
     Proposed Answer

    You have confused SQL Server 2005 and SQL Server 2008 when referencing assemblies, you should use one or the other.

    When looking at the assembly version 9.0.242.0 is for SQL 2005 and version 10.0.0.0 is SQL 2008. Step 4 seems to be using 2005 when the rest is 2010.

     

     


    http://www.sqlis.com | http://www.konesans.com