【问题标题】:How to get SMO application working on another Machine如何让 SMO 应用程序在另一台机器上运行
【发布时间】:2012-04-11 20:25:34
【问题描述】:

我使用 SMO 编写了一个应用程序,它在我的开发 PC 上安装并运行良好,甚至安装在另一个位置并运行它, 但是当我将它移到另一台机器上时,它会出现以下错误

Log Name:      Application
Source:        .NET Runtime
Date:          4/10/2012 12:03:56 PM
Event ID:      1026
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      ip-0A3AF6C2
Description:
Application: DataExport.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.SqlServer.Management.Common.ConnectionFailureException
Stack:
   at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()
   at DataExport.Data.SqlDataService.GetTableNames(System.String)
   at DataExport.Adapter.DataExportAdapter.GetTableNames(System.String)
   at DataExport.DataExportForm.SetInitialEditDisplay(DataExport.Adapter.IDataExportAdapter)
   at DataExport.DataExportForm..ctor(DataExport.Adapter.IDataExportAdapter)
   at DataExport.Program.Main()

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name=".NET Runtime" />
    <EventID Qualifiers="0">1026</EventID>
    <Level>2</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2012-04-10T11:03:56.000Z" />
    <EventRecordID>72945</EventRecordID>
    <Channel>Application</Channel>
    <Computer>ip-0A3AF6C2</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Application: DataExport.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.SqlServer.Management.Common.ConnectionFailureException
Stack:
   at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()
   at DataExport.Data.SqlDataService.GetTableNames(System.String)
   at DataExport.Adapter.DataExportAdapter.GetTableNames(System.String)
   at DataExport.DataExportForm.SetInitialEditDisplay(DataExport.Adapter.IDataExportAdapter)
   at DataExport.DataExportForm..ctor(DataExport.Adapter.IDataExportAdapter)
   at DataExport.Program.Main()
</Data>
  </EventData>
</Event>

我不知道如何解决这个问题,SMO dll 包含在包中

旧版本的 smo(10 之前)是否有可能覆盖所包含的 dll?

【问题讨论】:

  • 如果您可以显示发生异常的代码及其周围的一点点,这可能会有所帮助(例如,ISalonDataExport.DataExportForm..ctor 会很有趣)。我确定你已经检查过了,但你没有使用 localhost 或任何东西,而且 sql 服务器在另一台机器上?
  • 它从 app.config 中的加密部分加载配置。
  • "旧版本的 smo (pre 10) 是否有可能覆盖所包含的 dll? - 是的,我想是的......这可能不是一个确切的答案,更多的是你尝试过这个......但我在 smo 和部署方面遇到了类似的问题,我最终从我的复制了与 smo 相关的 dll sql 实例到远程机器上。确保在您的解决方案中也使用它们。喜欢删除,并通过浏览到您复制的 dll 重新添加它们。
  • 崩溃的方法如下 public List GetTableNames(string connectionString) { var conn = new SqlConnection(connectionString); var server = new Server(new Microsoft.SqlServer.Management.Common.ServerConnection(conn)); server.ConnectionContext.Connect(); var mydb = server.Databases["mydb"]; return (from Table table in mydb.Tables select table.Name).ToList(); }

标签: c# sql-server visual-studio-2010 smo


【解决方案1】:

好的解决方案是 SMO 10 仅适用于 Server 2008,它不适用于 2005 SQL Express 所以答案是将版本降低到 9.0

【讨论】:

    猜你喜欢
    • 2019-10-26
    • 2018-04-21
    • 1970-01-01
    • 1970-01-01
    • 2017-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-19
    相关资源
    最近更新 更多