0

I wrote an application using SMO it installs and runs fine on my dev pc, even installing in another location and running it, but when i move it to another machine it gives the following error

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>

I have no idea how to solve this, the SMO dlls are included in the package

File list after installation

Is there any possiblility that the older version of smo (pre 10) is overriding the dlls included?

Theresa Forster
  • 1,914
  • 3
  • 19
  • 35
  • It may help if you can show the code where the exception occurs from and a little bit around it (ISalonDataExport.DataExportForm..ctor would be interesting, for example). I am sure you have checked this, but you aren't using localhost or anything and the sql server is on a different machine? – kmp Apr 10 '12 at 11:19
  • its loading the config from an encrypted section in the app.config. – Theresa Forster Apr 10 '12 at 11:21
  • "Is there any possiblility that the older version of smo (pre 10) is overriding the dlls included?" - Yes, i think so... Sho this might not be an exact answer, more of a have you tried this... but i'v had similar issues with smo & deployments, I ended up copying the smo related dlls from my sql instance on to the remote machine. Make sure in your solution that youre using them as well. Like remove, and re-add them by browsing to you're copied dll's. – Rohan Büchner Apr 10 '12 at 11:26
  • the method that is crashing is as follows 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(); } – Theresa Forster Apr 10 '12 at 11:27

1 Answers1

0

OK the solution is that SMO 10 is only for Server 2008, it will not work with 2005 SQL Express So the answer was to lower the version to 9.0

Theresa Forster
  • 1,914
  • 3
  • 19
  • 35