"Exception has been thrown by the target of an invocation" Error

  • Help pls new here, i keep getting this:

    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig,
    Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
    Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
    BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.
    InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers,
    CultureInfo culture, String[] namedParams) at
    Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

    i am using the script to unzip files

  • kelch4n_35 - Wednesday, January 3, 2018 7:15 PM

    Help pls new here, i keep getting this:

    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig,
    Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
    Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
    BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.
    InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers,
    CultureInfo culture, String[] namedParams) at
    Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

    i am using the script to unzip files

    Normally you'd probably want to provide more information on what you are doing with what. I'll make some guesses - and that can give you an idea of what else you would want to provide. Is this in an SSIS package? Are you using a script task in the SSIS package? Is this an error you get just before the task actually executes?
    When ever you hit an error, try to turn up the logging and logging levels to get more information. And in general, check any and all logs you can find that may have information about whatever errors or issues you are experiencing.
    My first guess would be that you are using some package variables that you haven't declared in the script task. You need to explicitly declare them in the script task for them to be available to that task. That's one of the ways you can get that error.

    Sue

  • Sue_H - Wednesday, January 3, 2018 8:30 PM

    kelch4n_35 - Wednesday, January 3, 2018 7:15 PM

    Help pls new here, i keep getting this:

    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig,
    Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
    Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
    BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.
    InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers,
    CultureInfo culture, String[] namedParams) at
    Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

    i am using the script to unzip files

    Normally you'd probably want to provide more information on what you are doing with what. I'll make some guesses - and that can give you an idea of what else you would want to provide. Is this in an SSIS package? Are you using a script task in the SSIS package? Is this an error you get just before the task actually executes?
    When ever you hit an error, try to turn up the logging and logging levels to get more information. And in general, check any and all logs you can find that may have information about whatever errors or issues you are experiencing.
    My first guess would be that you are using some package variables that you haven't declared in the script task. You need to explicitly declare them in the script task for them to be available to that task. That's one of the ways you can get that error.

    Sue

    hi sorry for the lack of info, yes this is an SSIS oackage and i am using a script task, i got this error during the process, i did declare as shown below:

    #region Namespaces
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using System.IO.Compression;
    using System.IO;

    #endregion

    namespace ST_1df7a0accc1042de877a7d4b840d5be9
    {

        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
        {

       public void Main()
       {

        string zipfullpath = Dts.Variables["User::ProcessFilePath"].Value.ToString();
        string inputfolder = Dts.Variables["User::ProcessFolder"].Value.ToString();

        using (ZipArchive arch = ZipFile.OpenRead(zipfullpath))
        {
          foreach (ZipArchiveEntry entry in arch.Entries)
          {
           entry.ExtractToFile(Path.Combine(inputfolder, entry.FullName));
          }
        }

       
        File.Delete(zipfullpath);
        // TODO: Add your code here

        Dts.TaskResult = (int)ScriptResults.Success;
       }

       enum ScriptResults
       {
        Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
        Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
       };
       #endregion

        }
    }

  • kelch4n_35 - Wednesday, January 3, 2018 8:40 PM

    hi sorry for the lack of info, yes this is an SSIS oackage and i am using a script task, i got this error during the process, i did declare as shown below:

    #region Namespaces
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using System.IO.Compression;
    using System.IO;

    #endregion

    namespace ST_1df7a0accc1042de877a7d4b840d5be9
    {

        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
        {

       public void Main()
       {

        string zipfullpath = Dts.Variables["User::ProcessFilePath"].Value.ToString();
        string inputfolder = Dts.Variables["User::ProcessFolder"].Value.ToString();

        using (ZipArchive arch = ZipFile.OpenRead(zipfullpath))
        {
          foreach (ZipArchiveEntry entry in arch.Entries)
          {
           entry.ExtractToFile(Path.Combine(inputfolder, entry.FullName));
          }
        }

       
        File.Delete(zipfullpath);
        // TODO: Add your code here

        Dts.TaskResult = (int)ScriptResults.Success;
       }

       enum ScriptResults
       {
        Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
        Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
       };
       #endregion

        }
    }

    No idea if it's while the script task is running. Try logging in the task to get an idea on where things are breaking down - here is an example from the documentation:
    Logging in the Script Task
    And here is a post with similar alternatives:
    How to get detail error description of a script task

    Sue

  • This was removed by the editor as SPAM

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply