1
votes

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; }
}
2
You have omitted the start of the error message - which is probably the most important part. :) - Ulric
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
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
No it's same machine. Successfully compile and build, error is fire during execution. - Jakub

2 Answers

1
votes

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);
0
votes

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