我在控制台应用程序中使用了这段代码,它可以工作。(来自MSDN)
使用系统的
;使用Microsoft.SqlServer.Dts.Runtime;使用Microsoft.SqlServer.Dts.Pipeline;使用Microsoft.SqlServer.Dts.Pipeline.Wrapper;命名空间Microsoft.SqlServer.Dts.Samples {类程序{静态空主(string[] args) { Microsoft.SqlServer.Dts.Runtime.Package包=新的Microsoft.SqlServer.Dts.Runtime.Package();可执行的e=Microsoft.SqlServer.Dts.PipelineMicrosoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = (Microsoft.SqlServer.Dts.Runtime.TaskHost)e;MainPipe dataFlowTask = (MainPipe)thMainPipe.InnerObject;// Application对象将用于从其PipelineComponentInfos集合中获取PipelineComponentInfo的CreationName //。Microsoft.SqlServer.Dts.Runtime.Application();应用=新的Microsoft.SqlServer.Dts.Runtime.Application //向数据流中添加第一个ADO源。// CreationName属性需要一个应用程序实例。component1 = dataFlowTask.ComponentMetaDataCollection.New();"DataReader Source".CreationName;}
SQL 2019,VS 2019
在同一台机器上,但这次在SSIS中的“脚本任务”中,它不能在最后一行上工作:
集合“Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException:”中不存在
的“DataReader Source”。
我在控制台应用程序中引用了dll,所有版本都是15.0.0.0。
例如:C:\Program (x86)\Microsoft SQL Server\150\SDK\Assemblies\Microsoft.SqlServer.DTSPipelineWrap.dll
我在Microsoft.SqlServer.ADONETSrc上添加了引用,但没有结果。
我尝试使用不同版本的Mssql.Dts dll而没有成功。
为什么这些代码在控制台应用程序中运行,而不是在脚本任务中运行呢?
谢谢你的帮忙
发布于 2022-12-02 09:17:20
我找到了解决办法。由于与某些任务的兼容性原因,包含任务脚本的包在Visual中以32位模式运行。因此,我将Run64BitRuntime模式设置为true,现在得到所有对象。在控制台模式下,我确实处于64位。
问:是否有可能在保持32位的情况下获得这一结果?
https://stackoverflow.com/questions/74644624
复制相似问题