1

Hi when I building solution it's fine but during execution its fail with following error:

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 will mention that I successfully run it in SSIS with JavaScriptSerializer Deserializer.
Not sure what I am doing wrong?
Add external references for this class .Net40 (for SQL Server 2012 seems right).
Any suggestion?

Code sample below:

public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
    // dataResponse looks like that {"access_token":"bla","expires_in":222}
    // Old Code
    // JSONElements elements = new JavaScriptSerializer().Deserialize<JSONElements>(dataResponse);
    JSONElements elements = JsonConvert.DeserializeObject<JSONElements>(dataResponse);
}   

public class JSONElements
{
    public string access_token { set; get; }
    public int expired_in { set; get; }
}
NASSER
  • 5,900
  • 7
  • 38
  • 57
Jakub
  • 21
  • 4
  • 1
    You have omitted the start of the error message - which is probably the most important part. :) – Ulric Sep 08 '15 at 14:23
  • Message box pop in with Header 'Exception has been thrown by the target of an invocation.' Nothing else. This is within SSIS so I cannot debug script on its own. – Jakub Sep 08 '15 at 14:26
  • Are you now running this on a different machine than the machine you developed against? If so, you need to install the dll into the gac on the target machine – billinkc Sep 08 '15 at 14:33
  • See also http://stackoverflow.com/questions/11611165/add-third-party-dll-reference-in-ssis-script-component – billinkc Sep 08 '15 at 14:34
  • No it's same machine. Successfully compile and build, error is fire during execution. – Jakub Sep 08 '15 at 14:36
  • Your property name is `expired_in` but in your json its `expires_in`. Have you checked it? – NASSER Sep 08 '15 at 15:00
  • Sorry, it is a typo in post. And error is fired when SSIS script task is loaded not when get to place deserielizer do a job. I think is to library is not registered with GAC and when is execute SSIS makes copy and run from TEMP. From there calls external libraries. – Jakub Sep 08 '15 at 15:18

2 Answers2

1

Try Replacing

JsonConvert.DeserializeObject<JSONElements>(dataResponse);

with

System.Web.Script.Serialization.JavaScriptSerializer serial = new System.Web.Script.Serialization.JavaScriptSerializer();
JSONElements incoming = serial.Deserialize<JSONElements>(dataResponse);
Zoe
  • 27,060
  • 21
  • 118
  • 148
0

I think is to library is not registered with GAC and when is execute SSIS makes copy and run from TEMP. From there calls external libraries and looks in Registered places "Path" in System Variables. Try to modify it but cannot restart machine - its server without Microsoft SDK. So don't see any more solution for that

Jakub
  • 21
  • 4