We have an SSIS application running successfully using SQL Server 2012 and Visual Studio 2012 in which a SSIS Script Task (Visual Basic 2012) is utilised to programmatically generate SSIS packages with Data Flow tasks and execute these. We now face issues
when migrating from SQL Server 2012 to SQL Server 2016. We are out of ideas and would be grateful for any suggestions. The problem has been distilled down to the following simple SSIS Package with one Script Task and one Connection Managers entry for localhost.
================== Script Code - Start ==========================
#Region"Imports"
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
#EndRegion
<Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute()>
<System.CLSCompliantAttribute(False)>
PartialPublicClassScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
PrivateFunction AddConnection(ByRef
p AsPackage,ByVal cmAsConnectionManager)AsConnectionManager
Dim newCMAsConnectionManager = p.Connections.Add(cm.CreationName)
newCM.Name = cm.Name
newCM.ConnectionString = cm.ConnectionString
Return newCM
EndFunction
PublicSub Main()
''
'' instantiate runtime application and package
''
Dim appAsApplication =NewApplication()
Dim pAsPackage =NewPackage()
p.Name = "SSIS Dynamic DataFlow Example"
p.PackageType = DTSPackageType.DTSDesigner100
p.VersionBuild = 1
''
'' Add DataFlow Task to package
''
Dim eAsExecutable = p.Executables.Add("STOCK:PipelineTask")
Dim mainTaskHostAsTaskHost =CType(e,TaskHost)
Dim dataFlowTaskAsMainPipe =CType(mainTaskHost.InnerObject,MainPipe)
mainTaskHost.Name = "Main Data Flow"
''
' Source Connection - Use this package's Connection Managers Connection called "LocalHost"
'
Dim LocalSrceAsConnectionManager = AddConnection(p, Dts.Connections("LocalHost"))
'
Dim sourceDBAsIDTSComponentMetaData100 = dataFlowTask.ComponentMetaDataCollection.New
' sourceDB.Name = "SourceDatabase"
sourceDB.Name = "SourceDB"
' sourceDB.ComponentClassID = "DTSAdapter.OleDbSource"
sourceDB.ComponentClassID = "{165A526D-D5DE-47FF-96A6-F8274C19826B}" ' Ref: //msdn.microsoft.com/en-us/library/gg587414(v=sql.105).aspx
'
' Initialise the component and assign connection manager
'
Dim sourceInstanceAsCManagedComponentWrapper = sourceDB.Instantiate
sourceInstance.ProvideComponentProperties()
sourceDB.RuntimeConnectionCollection(0).ConnectionManagerID = LocalSrce.ID
EndSub
#Region"ScriptResults declaration"
EnumScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
EndEnum
#EndRegion
EndClass
================== Script Code - End ==========================
The script fails on the following statement:
sourceInstance.ProvideComponentProperties()
Failure:{"Exception from HRESULT: 0xC0048021"}
When drilling into the sourceInstance variable value the following error is seen:
{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: The component is missing, not registered, not upgradeable,
or missing required interfaces. The contact information for this component is "".
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParams)
at System.Dynamic.IDispatchComObject.GetMembers(IEnumerable`1 names)}
The References that are in place are:
Microsoft.SqlServer.DTSPipelineWrap
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.DTSPipelineWrap\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.SQLServer.DTSPipelineWrap.dll
Microsoft.SqlServer.ManagedDTS
C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.SqlServer.ManagedDTS\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ManagedDTS.dll
Microsoft.SqlServer.ScriptTask
E:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks\Microsoft.SqlServer.ScriptTask.dll
System
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll
System.Data
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll
System.Windows.Forms
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll
System.Xml
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll