-2

Possible Duplicate:
SQL Server SMO complains of missing DLL

I have the following code for backing up DB's which has worked with Windows Server 2003 on SQL Server 2005:

            ServerConnection ServerConn = new ServerConnection();
        try
        {
            ServerConn.ServerInstance = "(local)";
            ServerConn.LoginSecure = true;
            ServerConn.Connect();

            if (ServerConn.SqlConnectionObject.State == ConnectionState.Open)
            {
                Server svr = new Server(ServerConn);
                string[] DatabaseNames = GetDatabaseNames();
                foreach (string Database in DatabaseNames)
                {
                    Backup bkp = new Backup();
                    bkp.Devices.AddDevice(SanityConstants.DBBackupFolder + Database + ".bak", DeviceType.File);
                    bkp.Database = Database;
                    bkp.Action = BackupActionType.Database;
                    bkp.Initialize = true;
                    bkp.SqlBackup(svr);
                }
            }
        }

When this code is executed on a Windows Server 2008 32-bit machine, I get the following error:

"Backup failed for Server '[DT-COMP]'. -- Could not load file or assembly 'Microsoft.SqlServer.SqlEnum, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified."

SQL Server 2008 R2 is installed on this machine. I am able to replicate the issue on other Win Server 2008 machines.

Any ideas?

Community
  • 1
  • 1
Ciaran Gallagher
  • 3,895
  • 9
  • 53
  • 97
  • Based on your exception, you're missing an assembly reference... This isn't 'Express' edition by any chance? – Phill Jul 08 '11 at 11:03
  • 3
    [The answer](http://stackoverflow.com/questions/537613/sql-server-smo-complains-of-missing-dll/551403#551403) was found in about time required to paste the error message into the search box. Please use Google. – GSerg Jul 08 '11 at 11:04
  • I tried installing the SMO objects before. It didn't fix the issue. However, do I need to have updated SQL Server DLL's referenced in my program. I'm currently using the Microsoft.SqlServer.ConnectionInfo, Microsoft.SqlServer.ServiceBrokerEnum and Microsoft.SQLServer.Smo DLL's. Do I need a new set of DLL's to allow it to work? Also, do I also need the old DLL's for it to work with older versions of SQL Server? If so, where can I get these DLL's? – Ciaran Gallagher Jul 08 '11 at 11:26
  • GSerg you never answered the question, and the link you provided doesn't report the same problem. And the link you provided is to a question which doesn't even have an accepted answer. – Ciaran Gallagher Jul 13 '11 at 16:37

1 Answers1

0

The Error you have shown is not due to the Code you have written, but its due to the SqlServer Installation Problem, Repair the SqlServer in your system and try again. And if it also not working stop the SqlServer and Start again, detach the database and re-attach it.

  • SQL Server 2008 with R2 was successfully installed yesterday ont he machine. Is it missing an optional component, do you think? – Ciaran Gallagher Jul 08 '11 at 13:21
  • May, be the same error i had got previously when doing the Backup of a database. Then, when i repaired the Sql Server again the error was not coming later. – Sai Kalyan Kumar Akshinthala Jul 08 '11 at 13:25
  • I've got this same issue across multiple machines though. I'll need to get in touch with those responsible for installing SQL Server and see if they can perform a repair, or try installing with all possible components. – Ciaran Gallagher Jul 08 '11 at 16:11