Could not load file or assembly 'Microsoft.SqlServer.BatchParserClien.dll File Name


I have this crazy issue where a SMO operation is failing, and the only difference is this odd file in my bin folder:

Could not load file or assembly 'Microsoft.SqlServer.BatchParserClien.dll

NOTE: That is not a typo, that is the actual name of the file in the file system.

I don't know what to make of this, I have never seen anything like this in my bin folder before.

The operation that I am doing is :

var distributor = new ReplicationServer(conn);
                    if (!distributor.DistributorInstalled)
                        distributor.InstallDistributor((string)null, distributionDb);

I am using the Microsoft.SqlServer.SqlManagementObjects nuget package with version 140.17177.0.

The fusion log in the exception is :

=== Pre-bind state information === LOG: DisplayName = Microsoft.SqlServer.BatchParser, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91 (Fully-specified) LOG: Appbase = file:///C:/tfs/Back Office/Persistence/ReplicationManagement/Worker/bin/Debug/ LOG: Initial PrivatePath = NULL Calling assembly : Microsoft.SqlServer.BatchParserClient, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\tfs\Back Office\Persistence\ReplicationManagement\Worker\bin\Debug\Worker.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Post-policy reference: Microsoft.SqlServer.BatchParser, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91 LOG: Attempting download of new URL file:///C:/tfs/Back Office/Persistence/ReplicationManagement/Worker/bin/Debug/Microsoft.SqlServer.BatchParser.DLL. ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

The BatchParser file does exist in the bin with the same version specified. I have one project where this works, and the only difference is the file name in the output.

asked on Stack Overflow Oct 16, 2017 by hivie7510

3 Answers


I had a similar issue. I have an SMO application which uses the Microsoft.SqlServer.SqlManagementObjects nuget package.

The app all runs perfectly on my p.c however when it came to deploying it and running it on our app server i was getting the error.

Could not load file or assembly 'Microsoft.SqlServer.BatchParser.dll' or one of its dependencies. The specified module could not be found.

To fix the issue I needed to build the project again targeting x86 platform. I then also had to install the corresponding x86 C++ Redistributable Package

answered on Stack Overflow Nov 8, 2017 by Chris Stubbs

For Visual Studio 2017 download this nuget package

Open PM Console and paste below line

Install-Package Microsoft.SqlServer.SqlManagementObjects -Version 140.17283.0

More Information about latest builds

answered on Stack Overflow Sep 6, 2018 by AZ_

I had a similar issue and i had to set my Platform target to be Any CPU and to check Prefer 32-bit.

answered on Stack Overflow Apr 27, 2020 by SubqueryCrunch

User contributions licensed under CC BY-SA 3.0