【发布时间】:2012-06-29 20:51:42
【问题描述】:
我有一个 C# 项目,我在其中使用 Microsoft.SqlServer.Management.Smo、Microsoft.SqlServer.batchparser.dll 和一些其他 SqlServer dll。
当我在开发机器上运行代码时,它工作正常,但是当我尝试在干净的机器(客户端机器)上运行可执行文件时,它失败并抛出这个异常:
Microsoft.SqlServer.Management.Smo.FailedOperationException:数据库“testdb”的 ExecuteNonQuery 失败。 ---> System.IO.FileLoadException:无法加载文件或程序集“Microsoft.SqlServer.BatchParser.dll”或其依赖项之一。此应用程序无法启动,因为应用程序配置不正确。重新安装应用程序可能会解决此问题。 (来自 HRESULT 的异常:0x800736B1) 在 System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly 程序集,字符串名称,布尔 throwOnError,布尔 ignoreCase,ObjectHandleOnStack 类型) 在 System.Reflection.RuntimeAssembly.GetType(字符串名称,布尔 throwOnError,布尔 ignoreCase) 在 Microsoft.SqlServer.Management.Common.ServerConnection.GetStatements(字符串查询,ExecutionTypes executionType,Int32& statementsToReverse) 在 Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(字符串 sqlCommand,ExecutionTypes executionType) 在 Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands,ExecutionTypes executionType) 在 Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection 查询,ExecutionTypes executionType) 在 Microsoft.SqlServer.Management.Smo.Database.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
现在,如果我在客户端机器上安装“Microsoft SQL Server 2012 共享管理对象”,它就会开始工作。
我想确切地找出导致批处理解析器失败的依赖项。我从“Microsoft SQL Server 2012 Shared Management Objects”安装程序中抓取了这些程序集并将它们复制到 GAC 中,但仍然是同样的错误。
我的问题是: 1 - 如何找到 batchparser.dll 的依赖项并将其附加到我的安装程序? 2 - 我可以在我的应用程序之前安装 sql server 2012 的可再分发包。
谢谢, 阿里
【问题讨论】:
标签: c# .net sql-server