我试图在SSIS脚本任务中运行它:
#region Namespaces
using System;
using System.Data;
using System.IO;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using RestSharp;
using Newtonsoft.Json;
using WinSCP;
#endregion
namespace ST_a949541a7e9d41c2b7ae8d402e8adb24
{
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
string requestUrl = "www.google.com";
var client = new RestClient(requestUrl);
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}
利用RestSharp net4库。它似乎构建/编译正常,但是当我尝试运行我的包时,我在脚本任务上得到这些错误:
Exception has been thrown by the target of an invocation.
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()
我在非SSIS项目中使用相同的库执行完全相同的代码并且它可以正常工作。这里发生了什么?