FRReg
FRReg

Reputation: 37

Missing reference for ADO.Net in SSIS script C#

I use this code in a console app and it works. (from MSDN)

using System;  
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Pipeline;  
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;  
  
namespace Microsoft.SqlServer.Dts.Samples  
{  
  class Program  
  {  
    static void Main(string[] args)  
    { 
                 Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
                Executable e = package.Executables.Add("STOCK:PipelineTask");
                Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = (Microsoft.SqlServer.Dts.Runtime.TaskHost)e;
                MainPipe dataFlowTask = (MainPipe)thMainPipe.InnerObject;

                // The Application object will be used to obtain the CreationName  
                //  of a PipelineComponentInfo from its PipelineComponentInfos collection.  
                Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();

                // Add a first ADO NET source to the data flow.  
                //  The CreationName property requires an Application instance.  
                IDTSComponentMetaData100 component1 = dataFlowTask.ComponentMetaDataCollection.New();
                component1.Name = "DataReader Source";
                component1.ComponentClassID = app.PipelineComponentInfos["DataReader Source"].CreationName;
    }  
  }  
}  

SQL 2019, VS 2019

On the same machine but this time in a "Script Task" in SSIS it doesn't work on the last line :

Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException: '"DataReader Source" does not exist in the collection "PipelineComponentInfos".

I have referenced the dlls like in my console app, all versions are 15.0.0.0

For example :C:\Program Files (x86)\Microsoft SQL Server\150\SDK\Assemblies\Microsoft.SqlServer.DTSPipelineWrap.dll

I added the reference on Microsoft.SqlServer.ADONETSrc, but no result.

I tried to use different versions of Mssql.Dts dlls without succes

Why this code runs in console app and not in a script task ?

Thanks for your help

Upvotes: 0

Views: 361

Answers (1)

FRReg
FRReg

Reputation: 37

I found a solution. My package containing the Task script was running in 32-bit mode in Visual Studio for compatibility reasons with some tasks. So I set the Run64BitRuntime mode to true and I now get all objects. In console mode I was indeed in 64 bits.

Question: would it be possible to obtain this result while remaining in 32 bits?

Upvotes: 0

Related Questions