我在尝试打开自定义控制流组件的编辑器时遇到问题。我试图复制包所在的dll,但没有帮助。如果我做错了什么或如何解决此问题,请告诉我。
Here is the code:
Main class inherits TASK
namespace SSIS.Custom.ControlFlowUI
{
[DtsTask (
DisplayName = "CopyTable",
Description = "A custom Unzip task for demonstration purposes.",
TaskType = "CustomComponent",
UITypeName = "CopyTableTaskUI, CopyTable, Version=1.0.0.0,Culture=Neutral, PublicKeyToken=9097a336d1055e0b")]
public class CopyTable : Task
{
#region Override methods
public override DTSExecResult Validate(Connections connections,
VariableDispenser variableDispenser, IDTSComponentEvents componentEvents,
IDTSLogging log)
{
return base.Validate(connections, variableDispenser, componentEvents, log);
}
public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
{
try
{
ValidateSchema(@"GGN19\MSSQL12");
// Return success.
return DTSExecResult.Success;
}
catch (System.Exception exception)
{
// Capture exceptions, post an error, and fail validation.
return DTSExecResult.Failure;
}
}
#endregion
#region Public methods
public string ValidateSchema(string tableName)
{
GetTableList(tableName);
return "";
}
private List<string> GetTableList(string ServerName)
{
List<string> lTables = new List<string>();
try
{
SqlConnection dbConn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TestingTmp;Data Source=" + ServerName);
SqlCommand dbCmd = new SqlCommand("Select NAME from sysobjects where type ='U';", dbConn);
dbConn.Open();
SqlDataReader SqlDR = dbCmd.ExecuteReader();
while (SqlDR.Read())
{
lTables.Add(SqlDR.GetString(0));
}
dbConn.Close();
}
catch (Exception ex) { }
return lTables;
}
private bool ValidateTableSchema(string ServerName, string table1, string table2)
{
SqlConnection dbConn = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=msdb;Data Source=" + ServerName);
SqlCommand dbCmd = new SqlCommand("Select * from '" + table1 + "';", dbConn);
dbConn.Open();
SqlDataReader SqlDR = dbCmd.ExecuteReader();
DataTable schema = SqlDR.GetSchemaTable();
dbCmd = new SqlCommand("Select * from '" + table2+ "';", dbConn);
dbConn.Open();
SqlDR = dbCmd.ExecuteReader();
DataTable schema2 = SqlDR.GetSchemaTable();
return schema.Equals(schema2);
}
#endregion
}
UI Class
namespace ControlFlowUI
{
public class CopyTableTaskUI : IDtsTaskUI
{
#region // Fields
private TaskHost _taskHost;
#endregion
#region Properties
#endregion
#region Methods
public void Initialize(TaskHost taskHost, IServiceProvider serviceProvider)
{
_taskHost = taskHost;
}
public ContainerControl GetView()
{
return new CopyTableFrm(_taskHost);
}
#endregion
#region IDtsTaskUI Members
public void Delete(IWin32Window parentWindow)
{
throw new NotImplementedException();
}
public void New(IWin32Window parentWindow)
{
throw new NotImplementedException();
}
#endregion
}
}
错误与附加到自定义控制流的用户界面有关,基本上你可以创建两种类型的控制流组件一种是简单的转换,另一种你也可以有一些 UI 来获取用户输入,ssis 将允许你双击在组件上并提供值...所以当我双击 com 以获取 UI 时,它会抛出错误.. 标题:Microsoft Visual 无法显示此任务的编辑器。无法加载类型名称“CopyTableTaskUI, CopyTable, Version=1.0.0.0,Culture=Neutral, PublicKeyToken=9097a336d1055e0b”指定的任务用户界面。无法加载文件或程序集“CopyTable,Version=1.0.0.0,Culture=neutral,PublicKeyToken=9097a336d1055e0b”或其依赖项之一。这