This is a possible duplicate question of this post, however my error is different and far less readable.
Right now, I have an SSIS package that only contains a script task. Inside of that script task, I have Microsoft.Exchange.WebServices.dll referenced and I have it included in the namespace.
Whenever I don't take use of any of the methods and classes defined in WebServices, the script runs perfectly. However, whenever I do make use of them, the entire script fails and won't even make it to a break point on the first line... It also throws the 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()
Any ideas? When I run my same code outside of this SSIS script task (in its own project) it works fine.
UPDATE
I'm updaing this post to include more potentially useful information. The code in my Script Task looks like this:
public void Main()
{
string _SharedBox = "user@domain.com";
ExchangeService service = new ExchangeService();
service.AutodiscoverUrl(_SharedBox);
service.UseDefaultCredentials = true;
//... goes on, but the rest is commented out for now.
}
I think that Microsoft.Exchange.WebServices
might not be included properly and that's the issue, however I'm not sure what's wrong with it. I have the DLL sitting inside of the VS solution but outside of the SSIS project. I have then added it as a reference in the Script Task - which is the part I'm not sure about. I initially tried including WebServices
via a NuGet package, however, I've come to realize that you can't use NuGet in a Script Task. Here's what my solution looks like in the Script Task:
Thanks for any help in advance!