我正在尝试从一个简单的控制台应用程序运行一个 SSIS 包。不幸的是我遇到了一些错误`
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);
}
}
}
我在实例化 IntegrationServices 类型的 IntegrationServices 对象时得到以下信息。 我收到以下错误。
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
最佳答案
我的控制台应用程序也有同样的问题。按照 Microsoft docs 上的所有步骤进行操作它没有工作,得到与你完全相同的错误找不到方法:'Void Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection..ctor(System.Data.SqlClient.SqlConnection)'.
Microsoft 文档解决方案不适用于控制台应用程序 (.NET Core),它仅适用于控制台应用程序 (.NET Framework)。
我猜您正尝试在控制台应用程序 (.NET Core) 上运行?我将我的更改为 .NET Framework,它运行良好。
关于c# - 在 C# .NET 中运行 SSIS 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65618658/