Non-invocable member 'ScriptObjectModel.Variables' cannot be used like a method in SSIS script task

Bala Narasimha Challa 466 Reputation points
2021-03-04T11:22:32.22+00:00

Hi Team,
Have small set of code as show in bellow.

// TODO: Add your code here
MessageBox.Show(Dts.Variables["USER::BookingRefResult"].Value.ToString());

When am trying to debug this script task am getting bellow error

Severity Code Description Project File Line Suppression State
Error CS1955 Non-invocable member 'ScriptObjectModel.Variables' cannot be used like a method. ST_295b44f56f3e44d4a8f3ec535aa3d296 C:\Users\AppData\Local\Temp\2\Vsta\SSIS_ST150\VstafJtZCK6UokOavLxJonF_4A\VstasD6LoclKEESpAUJBeCXMGw\ScriptMain.cs 94 Active

When am trying to save this script task am getting bellow error
Scripts contained in the package have compilation error. Do you want to save changes?

Please help on this.

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,452 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Monalv-MSFT 5,891 Reputation points
    2021-03-05T09:28:46.183+00:00

    Hi @Bala Narasimha Challa ,

    1.Please check if you add variable in the Script Task.
    74725-scripttask1.png

    2.Please set breakpoint in the script of the Script Task.
    The following link will be helpful:
    Script Task Debugging in SQL Server Integration Services (SSIS)

    Best regards,
    Mona


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Yitzhak Khabinsky 24,946 Reputation points
    2021-03-05T13:50:47.277+00:00

    Hi @Bala Narasimha Challa ,

    SSIS packages variable names are case-sensitive.

    That's why in your source code line:

    MessageBox.Show(Dts.Variables["USER::BookingRefResult"].Value.ToString());  
    

    the variable name shall be User::BookingRefResult instead of the USER::BookingRefResult
    You would need to check the varaible name in the Variables pane outside of the SSIS Script Task editor.

    All this is in addition to what Mona already pointed out in her answer.

    Before using variables in your script (i.e. before clicking on 'Edit Script...' button), select variables to be used in your script in 'ReadOnlyVariables' or in 'ReadWriteVariables'.

    0 comments No comments