No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))当我运行此代码时: //// Get Data Flow task TaskHost tHost = pkgOut.Executables[0] as TaskHost; MainPipe dataFlowTask = (MainPipe)tHost.InnerObject;我正在使用的代码如下: public void Main() { // Set Project Variables List<string> pkgVars = new List<string> { @"pPR_SSIS_Catalog_Server", @"pPR_SSIS_Catalog_Project", @"pPR_SSIS_Catalog_Folder" }; // Get Package String pkgLocation = @"C:\PATH\TO\TEMPLATE\PACKAGE\a_Load_SAP_Template.dtsx"; Application app = new Application(); Package pkgIn = app.LoadPackage(pkgLocation, null); String pkgName = "DynamicPackage"; // Add Connections (cos they're project connections and aren't stored in package) ConnectionEnumerator allConns = Dts.Connections.GetEnumerator(); while ((allConns.MoveNext()) && (allConns.Current != null)) pkgIn.Connections.Join(allConns.Current); // Convert new package to XML so we can cheat and just do a find and replace XmlDocument pkgXML = new XmlDocument(); pkgIn.SaveToXML(ref pkgXML, null, null); // Replace strings // Set SAP table String pkgStr = pkgXML.OuterXml.ToString(); pkgStr = pkgStr.Replace("#SAP_SRC_TABLE#", "MyF-ingSAPTables"); // Replace SAP Table Name // Set Project Variables references == values -- REMEMBER TO CHECK FOR INT PARAMS zzz foreach (string var in pkgVars) pkgStr = pkgStr.Replace(@"@[$Project::" + var + @"]", @"""" + Convert.ToString(Dts.Variables[var].Value) + @""""); // Convert back to XML XmlDocument newXML = new XmlDocument(); newXML.LoadXml(pkgStr); Package pkgOut = new Package(); pkgOut.LoadFromXML(newXML, null); //// Get Data Flow task TaskHost tHost = pkgOut.Executables[0] as TaskHost; MainPipe dataFlowTask = (MainPipe)tHost.InnerObject; // THIS IS WHERE THE CODE ERRORS new Application().SaveToXml(String.Format(@"D:\PATH\TO\SAVE\LOCATION\{0}.dtsx", pkgName), pkgOut, null); Dts.TaskResult = (int)ScriptResults.Success; }我尝试过:删除数据流以外的所有内容重新创建空白数据流重新创建软件包在脚本中制作了一个程序包并创建了数据流(此方法有效,但是当我打开程序包时,数据流没有出现...可能添加了错误,但在运行TaskHost部分时可以看到它)我不确定我还能尝试什么,我已经看到可能需要重新注册一些.dll的信息,但是我没有管理员权限,所以我不希望遇到麻烦的地方不知道是否行得通.任何帮助将不胜感激.谢谢解决方案已修复,是由于正在加载的.DLL版本不同.加载了旧版本,一切顺利.Purpose: I have an SSIS Solution with various packages, one set of these packages is currently created with a package per table due to them having different structures. The aim is to create a template package (done), update variables/table names (done), reinitialise and re-map columns, execute package for each table.Problem: So, as you can tell, I'm up to the point that i need to reinitialise but I am unable to get to the data flow task and keep getting this error:No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))When I run this code: //// Get Data Flow task TaskHost tHost = pkgOut.Executables[0] as TaskHost; MainPipe dataFlowTask = (MainPipe)tHost.InnerObject;The code that I am using is below: public void Main() { // Set Project Variables List<string> pkgVars = new List<string> { @"pPR_SSIS_Catalog_Server", @"pPR_SSIS_Catalog_Project", @"pPR_SSIS_Catalog_Folder" }; // Get Package String pkgLocation = @"C:\PATH\TO\TEMPLATE\PACKAGE\a_Load_SAP_Template.dtsx"; Application app = new Application(); Package pkgIn = app.LoadPackage(pkgLocation, null); String pkgName = "DynamicPackage"; // Add Connections (cos they're project connections and aren't stored in package) ConnectionEnumerator allConns = Dts.Connections.GetEnumerator(); while ((allConns.MoveNext()) && (allConns.Current != null)) pkgIn.Connections.Join(allConns.Current); // Convert new package to XML so we can cheat and just do a find and replace XmlDocument pkgXML = new XmlDocument(); pkgIn.SaveToXML(ref pkgXML, null, null); // Replace strings // Set SAP table String pkgStr = pkgXML.OuterXml.ToString(); pkgStr = pkgStr.Replace("#SAP_SRC_TABLE#", "MyF-ingSAPTables"); // Replace SAP Table Name // Set Project Variables references == values -- REMEMBER TO CHECK FOR INT PARAMS zzz foreach (string var in pkgVars) pkgStr = pkgStr.Replace(@"@[$Project::" + var + @"]", @"""" + Convert.ToString(Dts.Variables[var].Value) + @""""); // Convert back to XML XmlDocument newXML = new XmlDocument(); newXML.LoadXml(pkgStr); Package pkgOut = new Package(); pkgOut.LoadFromXML(newXML, null); //// Get Data Flow task TaskHost tHost = pkgOut.Executables[0] as TaskHost; MainPipe dataFlowTask = (MainPipe)tHost.InnerObject; // THIS IS WHERE THE CODE ERRORS new Application().SaveToXml(String.Format(@"D:\PATH\TO\SAVE\LOCATION\{0}.dtsx", pkgName), pkgOut, null); Dts.TaskResult = (int)ScriptResults.Success; }I have tried:Removing everything but the data flowRecreated a blank data flowRecreated the packageMade a package in the script and created the data flow (this works but when i open the package, the data flow does not appear...might have added it wrong but it can see it when I run the TaskHost section)I am not sure what else I can try, I have seen information that I might need to re-register some .dlls but I do not have admin access and I'd prefer not to go through the hassle for something where I do not know whether it will work.Any help would be appreciated.Thanks, 解决方案 Fixed, was due to version difference in the .DLL that was being loaded. Loaded an older version and all went through fine. 这篇关于SSIS脚本任务-不支持接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-07 04:31