SQL Server SMO complains of missing DLL

dll, smo, sql-server

Solution

I was able to successfully run your code using the 10.* versions of the assemblies "Microsoft.SqlServer.ConnectionInfo", "Microsoft.SqlServer.Management.Sdk.Sfc" and "Microsoft.SqlServer.Smo". Try downloading the 2008 version of the SMO components, maybe it was a bug that they've now fixed.

Problem

Ok, I've scoured the web, BOL, various forums and I'm no closer to an answer...hopefully you fine folks can lend a hand... We've got a dozen or so SQL Servers (some 2k, some 2005) on a network. I'm using SMO objects in a .NET application to get some standard information. My problem appears to boil down to a missing DLL - Microsoft.SqlServer.BatchParser.dll. However, this DLL did not come with the other SQL DLLs (Microsoft.SqlServer.ConnectionInfo.dll, Microsoft.SqlServer.Smo.dll, Microsoft.SqlServer.SmoEnum.dll, Microsoft.SqlServer.SqlEnum.dll, etc...). I also downloaded the SS2005 feature pack from Microsoft's site that includes the SMO objects, but still no luck. The following code works, unless I uncomment the line that is currently commented, in which case I get the error below: ``` protected void btnArchive_Click(object sender, EventArgs e) { ServerConnection conn = new ServerConnection("my_server"); conn.LoginSecure = false; conn.Login = "my_login"; conn.Password = "my_password"; Server s = new Server(conn); Database d = s.Databases["my_database"]; //Table tbl = d.Tables["my_table"]; Response.Write(s.Name + " " + s.Information.RootDirectory + " " + d.CreateDate.ToShortDateString()); conn.Disconnect(); } ``` Error: Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. Note, I've also tried this from SSIS using VB.NET, same behavior. Any thoughts would be appreciated. Thanks.

Original source