views:

5346

answers:

6

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.

A: 

Just so we understand the issue properly, the Microsoft.SqlServer.BatchParser.dll is not installed in the Global Assembly Cache on your development machine? If so, you might want to start with re-installing the .NET Framework (the version of the Framework that you are targeting) to see if that resolves the issue.

You can also try using the .NET Framework Configuration tool to see if the assembly is indeed present in the Global Assembly Cache (GAC). This MSDN Article describes how to use this tool.

(A search of my hard drive did not return the Microsoft.SqlServer.BatchParser.dll assembly even though I can see it using the .NET Framework Configuration tool).

Tim Lentine
Thanks for the reply. Though, I don't specifically know where the Global Assembly Cache is located, I have searched the entire drive and that dll does not exist. I have also re-installed the latest framework (3.5 SP1).
+1  A: 

Are you running a x64 OS on your box? There appear to be problems with BatchParser.dll in 64-bit environments - usually it is recommended to download the SMO x64 Package (SQLServer2005_XMO_x64.msi) from Microsoft.

See information about this here.

Does that help at all?

Marc

marc_s
+1  A: 

I wanted to reply to Marc, but it says I need 50 reputation, which I don't have. I don't know how else to reply to someone. Apologies if I'm using the site wrong...

Marc, thank you for your reply. No, it's not a 64 bit OS. It's 32 bit Windows Server 2003 Standard Edition SP2. I did download the x86 package (SQLServer2005_XMO.msi) with no luck.

Henry - no worries about using the site "wrong" :-) Hmm... other than reinstalling that XMO feature pack, I don't have any other idea either :-( Sorry my tip wasn't helpful....
marc_s
+1  A: 

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.

tbreffni
+2  A: 

Installing the 2008 version of the SMO components, did the trick. Thanks, man.

Cristi Potlog
A: 

it comes as part of the 2005 or 2008 upgrade advisor.

noob1e dba