5

We upgraded our application to .NET 4.0 a while ago, and now need to add the ability to backup SQL Server 2008 databases from the app. However, it doesn't seem that SMO is available for .NET 4. Is there a workaround or better way to perform a database backup (note that our backups need to be user initiated over a website, so we cannot schedule them).

Beep beep
  • 18,873
  • 12
  • 63
  • 78

2 Answers2

3

Use BACKUP DATABASE?

Otherwise, try these One, Two

Community
  • 1
  • 1
gbn
  • 422,506
  • 82
  • 585
  • 676
2

You can still reference SMO from a .NET 4.0 application, even with it targeting the .NET 2.0 framework.

If you get the Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. exception, installing the latest version of the SQL Server SDK (SQL Server 2008 R2) should fix it, even if the machine is running an older version of SQL Server e.g. 2005.

John Mills
  • 10,020
  • 12
  • 74
  • 121
  • 2
    You can vote for 4.0 support for SMO here: https://connect.microsoft.com/SQLServer/feedback/details/643811/net-4-0-compatible-smo – RobSiklos Mar 10 '11 at 15:24