SQL 2012 - DTS Script Task - Exception has been thrown by the target of an invocation


  • The error is thrown while trying to access system variables from within DTS Script Task.

    String strPackageName = (string) Dts.Variables["System::PackageName"].Value;

    Same results with other variables, such as System::MachineName...

    Other "DTS" data is available, the following doesn't error out:

    String strSourceFileName = (string) Dts.Connections["SourceConnectionFlatFile"].ConnectionString;

    • Edited by Mike Vayser Saturday, July 26, 2014 10:28 PM
    Saturday, July 26, 2014 10:27 PM


All replies

  • Does System::PackageName included in the ReadOnlyVariables or ReadWriteVariables?

    • Edited by JamesEarnan Sunday, July 27, 2014 1:34 AM
    • Marked as answer by Mike Vayser Sunday, July 27, 2014 7:52 AM
    Sunday, July 27, 2014 1:17 AM
  • James, it was not included in either.  I added System::PackageName to ReadOnlyVariables and that resolved the issue.

    Thank you for your assistance.

    Sunday, July 27, 2014 7:52 AM