0

I have very little experience in SSIS packages and BI. I am writing a C# script that will reside in a SSIS package but I want to test it out in my own Visual Studio console application before I deliver it to the BI people who will put it in place.

So I have got a copy of a ScriptMain.cs file, I have put it in my project and I instantiate it and call its main function from my main function.

My problem is that the script needs to fetch variables from a Dts object, which is a Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptObjectModel. This class doesn't seem to have a constructor. How do I instantiate it or mock it away?

I have tried to use the Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase object that is the parent of the Dts object. The parent can be instantiated but the Dts is still null.

static void Main(string[] args)
        {
            var objectAboveTheDts = new Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase();

            //the code below does not work. Dts is null.
            objectAboveTheDts.Dts.Variables.Add("variable01", true, "OddSSISNamespace", "value01");
            objectAboveTheDts.Dts.Variables.Add("variable02", true, "OddSSISNamespace", "value02");

            ScriptMain scriptMain = new ScriptMain();
            scriptMain.Dts = objectAboveTheDts.Dts;

            //run the actual script
            scriptMain.Main();

            Console.WriteLine();
            Console.WriteLine("The end. Press any key to close window");
            Console.ReadKey();
        }
Dudute
  • 357
  • 1
  • 3
  • 11

0 Answers0