RegenerateID causing layout problems with Sequence containers and annotations
Hi -- I'm trying to build a .NET application (with BIDS 2005) that loads an SSIS package and then adds tasks and precedence constraints to it. I don't start with a new package because I want the resulting package to have annotations so the only
way I can think of is to modify a template package (with annotations). Here's my code. The problem I'm seeing stems from the line of code that calls the RegenerateID method of the pkg object. When this code is run as is, the sequence
container is properly added to the package but all annotations from the template package are removed. On the other hand, if I comment out the RegenerateID call, the annotations remain intact but the Sequence container is not visible on the BIDS design
surface. It is still in the package because I can see it in the Properties window dropdown. Also, if I try to manually add a Sequence container in BIDS with the same name as the "hidden" one, BIDS barks at me that there already exists
a sequence container with the same name. This odd behavior does not appear when control flow tasks are programmatically added to the package (haven't tried data flow tasks). It seems to be limited to sequence containers although I haven't
tried For Loop and ForEach Loop containers.
Anyone know a programmatic way that I can have annotations and Sequence containers in my SSIS packages (aside from manually creating them) ? Thanks for your help.
Imports Microsoft.SqlServer.Dts.Runtime
Module Module1
Sub Main()
Const template As String = "C:\Template.dtsx" 'contains annotations
Dim app As New Application()
Dim pkg As New Package()
'Load the template package.
pkg = app.LoadPackage(template, Nothing)
With pkg
.RegenerateID()
.Name = "Sequence Test"
'Add a sequence container.
Dim SeqCont As Executable = pkg.Executables.Add("STOCK:SEQUENCE")
Dim seq As Sequence = CType(SeqCont, Sequence)
seq.Name = "SEQ - Main Container"
'Save the package.
app.SaveToXml("C:\seqtest.dtsx", pkg, Nothing)
Console.WriteLine("Package created")
Console.WriteLine()
End With
Console.Read()
End Sub
End Module
Bill
December 23rd, 2010 11:11am