无法加载文件或程序集'Microsoft.SqlServer.BatchParserClien.dll 文件名

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

我有一个 SMO 操作失败的疯狂问题,唯一的区别是我的 bin 文件夹中的这个奇怪文件:

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

注意:这不是打字错误,这是文件系统中文件的实际名称。

我不知道这是怎么回事,我以前从未在我的 bin 文件夹中看到过这样的东西。

我正在做的操作是:

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

我正在使用版本为 140.17177.0 的 Microsoft.SqlServer.SqlManagementObjects nuget 包。

异常中的融合日志为:

=== Pre-bind state information === LOG: DisplayName = Microsoft.SqlServer.BatchParser, Version=14.100.0.0, 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=14.100.0.0, 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=14.100.0.0, 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.

指定版本相同的 BatchParser 文件确实存在于 bin 中。我有一个项目可以正常工作,唯一的区别是输出中的文件名。

我遇到了类似的问题。我有一个使用 Microsoft.SqlServer.SqlManagementObjects nuget 包的 SMO 应用程序。

该应用程序在我的 p.c 上运行完美,但是在部署它和 运行 在我们的应用程序服务器上时,我遇到了错误。

无法加载文件或程序集 'Microsoft.SqlServer.BatchParser.dll' 或其依赖项之一。找不到指定的模块。

为了解决这个问题,我需要针对 x86 平台再次构建项目。 然后我还必须安装相应的 x86 C++ Redistributable Package

对于 Visual Studio 2017 下载此 nuget 包

Install-Package Microsoft.SqlServer.SqlManagementObjects -Version 140.17283.0

More Information about latest builds

我有一个类似的问题,我必须将我的平台目标设置为任何 CPU 以检查首选 32 位。