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.
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.
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.
I know I'm very late to the party here, but this is still the first result when you google "smo batchparser".
When installing SMO 2014 (12.0.x) some DLLs are only installed to the GAC. To make your app work without having to manually install SMO in the target server, you must copy these DLLs with your app. Here are the paths where I got them from.
C:\Program Files\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll
C:\Program Files\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.Management.Sdk.Sfc.dll
C:\Program Files\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.Smo.dll
C:\Program Files\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.SmoExtended.dll
C:\Program Files\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.SqlEnum.dll
C:\Windows\assembly\GAC_64\Microsoft.SqlServer.BatchParser\12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.BatchParser.dll
C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.BatchParserClient\12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.BatchParserClient.dll
C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.SqlClrProvider\12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.SqlClrProvider.dll
To access the GAC files you will need to disable the windows built-in viewer using the instructions provided by this article.
An excerpt of the article for convenience:
Open the registry editor and add/set the HKLM\Software\Microsoft\Fusion\DisableCacheViewer DWORD value: 1
You need to install following package to solve the problem , I have solved this problem twice with this package hope it may work for everyone too...
Microsoft SQL Server 2005 Management Objects Collection The Management Objects Collection package includes several key elements of the SQL Server 2005 management API, including Analysis Management Objects (AMO), Replication Management Objects (RMO), and SQL Server Management Objects (SMO). Developers and DBAs can use these components to programmatically manage SQL Server 2005.
You can get from Feature Pack for Microsoft SQL Server 2005 - December 2008 from Microsoft site
http://www.microsoft.com/en-us/download/details.aspx?id=11988
But the link location of download page changes every-time if you don't find resource you can download it from my blog too.
I have also provided some tips and resources about this in my blog if you want http://rndp-android.blogspot.com/p/missing-microsoftsqlservermanagementsdk.html
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).
it comes as part of the 2005 or 2008 upgrade advisor.
Related
Someone has installed sql server on my machine, however i'm not sure what is the version currently installed. I tried running : Sql server installation center --> Installed Sql server features discovery report and the result was as follows:
I tried looking in the "Programs and features" section and I found this:
I also tried opening Sql server Services but its empty. Here's a screenshot:
The currently running the services are :
Currently I'm not sure what version is installed, I tried connecting to "." on Sql Management Studio but i got connection error and no instance was found.
Since you can't connect, probably the best thing to do is hunt it down on your file system. Go to your installation, it's probably located somewhere like this:
C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQSERVER\MSSQL\Binn
and find the sqlserver.exe file. Right-click and select Properties on the file. The Details tab of the properties window will show a product version. The product version isn't going to be a name you're super familiar with, but you can look up on the web what version numbers correspond to what product names. Here's one place that has a nice chart. SqlServerBuilds at Blogspot
If you do get management studio to connect, you can get the version quite quickly, either from the connection properties in the Object Explorer, or with the ad hoc query
Select # #Version
I uninstalled 2008 and 2014 version and now the discovery report shows Sql Server 2012 installation correctly
The existing answer is OK, but here is a simpler tip:
Search the entire drive C: for sqlservr.exe. Use the properties dialog in Explorer to determine the file version and Google it.
You can find out what's running with Process Explorer. It can show you the path and version.
I like to deploy SQLServer CE privately on my VSPackage application.
I already tried the following information:
Using Entity Framework with an SQL Compact Private Installation
as well as this one:
How to deploy SQL Server Compact Edition 4.0?
But I still get the following exception message:
The specified store provider cannot be found in the configuration, or is not valid
I guess the above methods do not work for me because my VSPackage will appear as a DLL, while the above methods work for an .EXE application.
Any suggestion how can I do it?
Thanks
Most likely, Visual Studio cannot find and load one of SQL Server Compact Edition assemblies. By default, Visual Studio don’t look dependent assembles in a VSPackage folder if VSPackage code have not explicit reference to such assembles. I described several ways to solve this problem here. Hope it help you.
I cannot figure out how to remedy this error when I select the SQL server object explorer.
Could not load file or assembly
'Microsoft.Data.Tools.Schema.Utilities.Sql.11 Version=11.1.0.0
Culture=neutral, PublicKeyToken=**** or one of its dependencies. The system cannot find the file specified.
I have asked on the microsoft forums but I figured people who actually work with this daily may have a better response. I am a new user with VS so my knowledge is limited. I have updated VS and I have SQL server 2012 installed on this machine.
Thank you in advance for helping me make sense of this error.
Getting the same with VS 2013, maybe the same root problem:
Could not load file or assembly
'Microsoft.Data.Tools.Schema.Utilities.Sql.12 Version=12.0.0
I was able to resolve this by getting the most recent version of Microsoft SQL Server Data Tools. This is under the tools menu:
Tools >> Extensions and Updates >> Updates
Hey, I've just finished writing a VB.NET application. Now I want to package the executable and the database ofcourse into a single installer file. I tried using QSetup, InstallShield to make SQL Server embedded into the setup file, and finally after hours of try&fail I have no idea. Anyone?
You can do a rightmouse on the properties of your Visual Studio Setup Project, and then there is this button 'Prerequisites'. There you can tick 'SQL Server Express ...' Or the 'SQL Server Compact 3.5'
link to image
You're probably best off just to set the connection file directly to the mdf, and attach it when the program is run. This is easier as it doesn't require a custom setup script to install the database to the database directory itself.
Note: Consider using the Compact Version, it's smaller, people don't like a full blown engine on their computer :)
InstallShield has a concept called Setup Prerequisites where you can teach it how to install additional packages along with your own. In older versions this would happen before calling your MSI. In newer versions you can have a "Feature" prerequisite where the prereq can associated to a feature and only installed if that feature is selected to be installed and after it's been selected but still before the main activity of your MSI occurs during the install execute sequence.
InstallShield also has a pattern for executing SQL scripts against your database instance so that you can then load your database into your newly installed instance.
All of this is quite powerful but it does take a bit of digging to learn.
As far as I know, anything but the SQL Server Compact Edition (SQL Server CE) cannot be embedded into your setup, really. Microsoft doesn't want that - you need to have SQL Server Express installed separately - any other edition can't even be shipped with your software (the client must have a license and installation separately).
You can indeed distribute SQL server with your custom application:
http://msdn.microsoft.com/en-us/library/bb264562(SQL.90).aspx
I'm developing a Windows Forms application using Visual Studio 2008 C# that uses an SQL Server Compact 3.5 database on the client. The client will most likely be 32 bit Windows XP or Windows Vista machines. I'm using a standard Windows Installer project that creates an MSI file and setup.exe to install the application on a client machine. I'm new to SQL Server Compact, so I haven't had to distribute a client database like this before now. When I run the setup.exe (on new Windows XP 32 bit with SP2 and Internet Explorer 7) it installs fine, but when I run the application I get this error:
Unable to load DLL 'sqlceme35.dll'. The specified module could not be found
I spent a few hours searching for this error already, but all I could find were issues relating to installing on 64 bit Windows and none relating to normal 32 bit that I'm using.
The install application copies the all the dependent files that it found into the specified install directory, including the System.Data.SqlServerCe.dll file (assembly version 3.5.1.0). The database file is in a directory called 'data' off the application directory, and the connection string for it is
<add name="Tickets.ieOutlet.Properties.Settings.TicketsLocalConnectionString" connectionString="Data Source=|DataDirectory|\data\TicketsLocal.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" />
Some questions I have:
Should the application be able to find the DLL file if it's in the same directory, that is, local to the application, or do I need to install it in the GAC? (If so, can I use the Windows Installer to install a DLL file in the GAC?)
Is there anything else I need to distribute with the application in order to use a SQL Server Compact database?
There are other DLL files also, such as MS interop for exporting data to Excel on the client. Do these need to be installed in the GAC or will locating them in the application directory suffice?
You don't need it to be in the GAC for SQL Server Compact to run, and it will pick them up from the application directory. There are several ways to deploy an SQL Server Compact project. The two main ways are:
Deploying the SQL Server Compact redistributable installer with your project, but this way is painful and also can be unistalled by the end user, or upgraded by Windows updates and breaking your application.
Including the DLL files in your application folder. Depending on the features of SQL Server Compact you are using (replication or whatever), there is a handful of DLL files to deploy in your application folder.
If you have SQL Server Compact installed on your machine, they are most likely located at "C:\Program Files\Microsoft SQL Server Compact Edition\v3.5". They can be added to the project in Visual Studio and then set their project output type to "copy always". And the main reference to System.Data.SqlServerCe that you have in your project references should have copy local set to true.
sqlceca35.dll
sqlcecompact35.dll
sqlceer35en.dll
sqlceoledb35.dll
sqlceqp35.dll
sqlcese35.dll
If you have these all set, then in your installer project all you have to include is the project output of this project and you're good. In my opinion this is the only way to go. It is a simple deployment, of a couple of files and you are in control of what DLL versions your application uses.
I hope that helps.
I had a similar problem, a Visual Studio 2008 Windows application targeting 32-bit Windows XP and Windows Vista that used SQL Server Compact 3.5 SP1 - that then got this error when installed on 64-bit Windows 7:
Unable to load DLL 'sqlceme35.dll'. The specified module could not be found
I was embedding an MSI for SQL Server Compact into the installer for the application.
Following this rather confused discussion on MSDN revealed that I needed to use the 64-bit MSI for SQL Server Compact on 64-bit machines. D'oh! That is, from page Microsoft SQL Server Compact 3.5 Service Pack 1 and Synchronization Services for ADO.NET version 1.0 Service Pack 1 for Windows Desktop I needed SSCERuntime-ENU-x64.msi rather than SSCERuntime-ENU-x86.msi for 64-bit machines.
How to: Deploy a SQL Server Compact Edition Database with an Application should help, at least with your first two questions.
In general, I think you should not install anything in the GAC for a single application.
The following provide a solution to the problem and an explanation also.
Troubleshooting: Can’t load SQL Server Compact DLL
SqlCeException on application's first use of SQL Server Compact
Laxmi Narsimha Rao Oruganti 's blog
I hope this helps.