I am trying to run an SSIS package from a simple console app. Unfortunately I am stuck on some errors`
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SqlServer.Management.IntegrationServices;
using System.Data.SqlClient;
namespace SSIStutorial
{
class Program
{
static void Main(string[] args)
{
// Variables
string targetServerName = "localhost";
string folderName = "Projects";
string projectName = "SSIS Tutorial";
string packageName = "Lesson 1.dtsx";
// Create a connection to the server
string sqlConnectionString = "Data Source = cgol1793109; Initial Catalog = TEST; Integrated Security=True;";
SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
// Create the Integration Services object
IntegrationServices integrationServices = new IntegrationServices(sqlConnection);
// Get the Integration Services catalog
Catalog catalog = integrationServices.Catalogs["SSISDB"];
// Get the folder
CatalogFolder folder = catalog.Folders[folderName];
// Get the project
ProjectInfo project = folder.Projects[projectName];
// Get the package
PackageInfo package = project.Packages[packageName];
// Run the package
package.Execute(false, null);
}
}
}
I get the following while instantiating the IntegrationServices object of the type IntegrationServices. I get the following error.
System.MissingMethodException HResult=0x80131513 Message=Method not found: 'Void Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection..ctor(System.Data.SqlClient.SqlConnection)'. Source=Microsoft.SqlServer.Management.IntegrationServices StackTrace: at Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices..ctor(SqlConnection sqlConnection) at SSIStutorial.Program.Main(String[] args) in C:\Users\kokoro\source\repos\SSIStutorial\Program.cs:line 26
Had the same issue with my console app. Followed all the steps on Microsoft docs and it didn't work, got exactly the same error as you Method not found: 'Void Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection..ctor(System.Data.SqlClient.SqlConnection)'.
The Microsoft docs solution doesn't work on a Console App (.NET Core), it only works on a Console App (.NET Framework).
I guess you are trying to run in on a Console App (.NET Core)? I changed mine to .NET Framework and it worked.
Referring to the official documentation, the steps you used to define a connection and to instantiate the IntegrationServices object are correct. This means that the issue is caused by the connection string. Try to remove the additional spaces, edit the Integrated security parameter, and use the master database as the Initial catalog:
string sqlConnectionString = "Data Source=cgol1793109;Initial Catalog=master;Integrated Security=SSPI;";
SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
User contributions licensed under CC BY-SA 3.0