Hi All,
I have migrated few packages which contains script component from 2005 to 2008 .
Everything else is working just fine except the script component.
Following is the code and error from one of the script component.
read olny var : User::ODSConnectionString,System::PackageName
read write :User::loadExecutionID,User::SQLConnectionString
CODE
------
' Microsoft SQL Server Integration Services user script component ' This is your new script component in Microsoft Visual Basic .NET ' ScriptMain is the entrypoint class for script components Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper Imports Microsoft.SqlServer.Dts.Runtime.Wrapper Imports System.Data.SqlClient <Microsoft.SqlServer.Dts.Pipeline.DtsPipelineComponent()> _<CLSCompliant(False)> _ <Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _<CLSCompliant(False)> _ Public Class ScriptMain Inherits UserComponent Dim pckName As String Dim ODSConnectionString, SQLConnectionString As String Dim sqlConn As SqlConnection Dim sqlReader As SqlDataReader Dim sqlComm, updComm As SqlCommand Dim updParam As SqlParameter Dim loadExecID As Integer Dim logMsg As String Public Overrides Sub PreExecute() Try pckName = Me.Variables.PackageName ODSConnectionString = Me.Variables.ODSConnectionString Dim connStr() As String = ODSConnectionString.Split(CType(";", Char)) Dim i, cnt As Integer Dim chkQuery, updQuery, selQuery As String 'Removing the "Provider=SQLOLEDB" clause as it is not required in 'SqlClient connection strings cnt = 0 For i = 0 To connStr.Length - 1 Dim elements() As String = connStr(i).Split(CType("=", Char)) If elements(0) <> "Provider" Then If cnt <> 0 Then SQLConnectionString += ";" End If SQLConnectionString += connStr(i) cnt = cnt + 1 End If Next sqlConn = New SqlConnection(SQLConnectionString) sqlConn.Open() chkQuery = "SELECT LoadExecutionID, Status from LoadExecutionDetail " & _" WHERE LoadExecutionID = " & _" (SELECT MAX(LoadExecutionID) from LoadExecutionDetail)" updQuery = "UPDATE LoadExecutionDetail SET STATUS = 'EXECUTING' " & _" WHERE LoadExecutionID = @LoadexecutionID" sqlComm = New SqlCommand(chkQuery, sqlConn) sqlReader = sqlComm.ExecuteReader sqlReader.Read() loadExecID = CType(sqlReader(0).ToString, Integer) If sqlReader(1).ToString.ToUpper = "FAILURE" Then sqlReader.Close() updComm = New SqlCommand(updQuery, sqlConn) updParam = New SqlParameter("@LoadExecutionID", SqlDbType.Int) updComm.Parameters.Add(updParam) updComm.Parameters("@LoadExecutionID").Value = loadExecID updComm.ExecuteNonQuery() ElseIf sqlReader(1).ToString.ToUpper = "EXECUTING" Then 'No need to do anything as loadExecID has been assigned with the correct value Else 'Fire an error as the status for the current run is not EXECUTING or FAILURE Dim specMsg As String = "INVALID Status FOR MAX(LoadExecutionID) in LoadExecutionDetail" Dim locStr1 As String = Me.ComponentMetaData.Name & " => " & Me.GetType.Name & " => " _& System.Reflection.MethodInfo.GetCurrentMethod.ToString logMsg = pckName & ":Failed in " & locStr1 & ":" & specMsg Me.ComponentMetaData.FireError(0, "", logMsg, "", 0, True) End If Catch ex As Exception Dim locStr1 As String = Me.ComponentMetaData.Name & " => " & Me.GetType.Name & " => " _& System.Reflection.MethodInfo.GetCurrentMethod.ToString logMsg = pckName & ":Failed in " & locStr1 & ":" & ex.Message Me.ComponentMetaData.FireError(0, "", logMsg, "", 0, True) End Try End Sub Public Overrides Sub myInput_ProcessInputRow(ByVal Row As MyInputBuffer) ' ' Add your code here ' Row.LoadExecutionID = loadExecID End Sub Public Overrides Sub PostExecute() Me.Variables.loadExecutionID = CStr(loadExecID) Me.Variables.SQLConnectionString = SQLConnectionString End Sub Public Overrides Sub ReleaseConnections() sqlConn.Close() End Sub End Class
----------------------------------------------------------------------- end of code
The error is pointed to
<Microsoft.SqlServer.Dts.Pipeline.DtsPipelineComponent()> _
<CLSCompliant(False)> _
<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _
<CLSCompliant(False)> _
which says "Attribute 'CLSCompliantAttribute' cannot be applied multiple times'
When I remove one of the above <CLSCompliant(False)> _ the code build shows success but once I save it and reopen script component its not even opening throwing an error "object reference not set to an instance of an object"
Full Error Message
------------------------
Package Validation Error (Package Validation Error)
===================================
Error at df_DepositStage [sc_get_LoadExecutionID [16]]: Microsoft.SqlServer.Dts.Pipeline.CannotCreateUserComponentException: Cannot create user component class. Make sure there is one class marked with SSISScriptComponentEntryPointAttribute in your script.
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.CreateUserScriptInstance()
Error at df_DepositStage [sc_get_LoadExecutionID [16]]: Microsoft.SqlServer.Dts.Pipeline.CannotCreateUserComponentException: Cannot create user component class. Make sure there is one class marked with SSISScriptComponentEntryPointAttribute in your script.
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.CreateUserScriptInstance()
Error at df_DepositStage [sc_get_LoadExecutionID [16]]: The binary code for the script is not found. Please open the script in the designer by clicking Edit Script button and make sure it builds successfully.
Error at df_DepositStage [SSIS.Pipeline]: "component "sc_get_LoadExecutionID" (16)" failed validation and returned validation status "VS_ISBROKEN".
Error at df_DepositStage [SSIS.Pipeline]: One or more component failed validation.
Error at df_DepositStage: There were errors during task validation.
(Microsoft.DataTransformationServices.VsIntegration)
------------------------------
Program Location:
at Microsoft.DataTransformationServices.Project.DataTransformationsPackageDebugger.ValidateAndRunDebugger(Int32 flags, DataWarehouseProjectManager manager, IOutputWindow outputWindow, DataTransformationsProjectConfigurationOptions options)
at Microsoft.DataTransformationServices.Project.DataTransformationsProjectDebugger.LaunchDtsPackage(Int32 launchOptions, ProjectItem startupProjItem, DataTransformationsProjectConfigurationOptions options)
at Microsoft.DataTransformationServices.Project.DataTransformationsProjectDebugger.LaunchActivePackage(Int32 launchOptions)
at Microsoft.DataTransformationServices.Project.DataTransformationsProjectDebugger.LaunchDtsPackage(Int32 launchOptions, DataTransformationsProjectConfigurationOptions options)
at Microsoft.DataTransformationServices.Project.DataTransformationsProjectDebugger.Launch(Int32 launchOptions, DataTransformationsProjectConfigurationOptions options)
I am not great with vb script ... ANY HELP IS HIGHLY APPRECIATED ..stuck big time on this .
Please let me know in case any further detail is required.
Thanks and Regards
Praveen Uppath