c# - 无法加载文件或程序集 'Microsoft.SqlServer.Smo,版本 = 10.0.0

标签 c# sql-server winforms tsql smo

  • 操作系统:Microsoft Windows NT 5.2.3790 Service Pack 2 版本:2.0.50727.42

正在做:创建表...

Rec: system.m.FileNotFoundexception: could not load file or assembly 'microsoft.sqlserver.smo, version=10.0.0.0, culture=neutral File name: 'microsoft.sqlserver.smo, version=10.0.0.0, culture=neutral, PublicKeyToken=89845dcd8080cc91' at claimsure.Forml.Runsqlscript(string connstring, streamReader sr) at myapp.Forml.bw_Dowork(object sender, DoworkeventArgs e) 'MN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value (NKLm\software\microsoft\Fusion!enableLog] (DwoRD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value (NKLm\software\microsoft\Fusion!enableLog).

在装有 SQL Server 2005 的 Windows 2003 服务器上运行我的应用程序时出现上述错误。

我知道有一个解决方案可以从 http://www.microsoft.com/en-us/download/details.aspx?id=24793 下载 SQLServer2005_XMO

我已经这样做了,但是安装后需要重启服务器,暂时不可行。

我需要使用服务器对象。

 using Microsoft.SqlServer.Management.Smo;
 using Microsoft.SqlServer.Management.Common;  

        using (SqlConnection connection = new SqlConnection(connString))
        {
            Server server = new Server(new ServerConnection(connection));
            server.ConnectionContext.StatementTimeout = 2400;
            server.ConnectionContext.ExecuteNonQuery(sqlString);

        }

是否可以将 dll 加载到与我的应用程序相同的目录中并从代码中引用它?

谢谢。

编辑:添加了完整的错误

最佳答案

通过构建 MSI 安装程序并包含所有必需的 DLL 解决了这个问题。 谢谢指点。

关于c# - 无法加载文件或程序集 'Microsoft.SqlServer.Smo,版本 = 10.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13090319/

相关文章:

c# - 如何在 ASMX 中实现 OAuth 2.0(网络引用)?

c# - 当我尝试加入 2 个数据表时,对象引用未设置为对象的实例

c# - 使用 WPF 数据绑定(bind)设计响应式 UI

sql - 在 SQL Server 中对 NVARCHAR(MAX) 列建立索引

C# 如何像组合框一样制作列表框下拉列表?

c# - .NET 中的事件签名 - 使用强类型 'Sender' 吗?

.net - 如何跨多个开发人员管理和捕获数据库更改?

sql-server - 主键删除需要多长时间?

c# - 当所有 View 都被停用时,如何阻止 Caliburn Micro 关闭应用程序?

c# - Windows Forms .NET 4.5 中的 Toast 通知