Nick Zulanas Nick Zulanas -3 years ago 265
C# Question

DTS Script Task: Runtime Error in SSIS task due to referenced DLLs

I have been researching and testing this error for a while now.
enter image description here

I have commented out all of my code beside my Try:Catch to try to located the issue more easily. The code looks like this:

using DataLoader;
//other references and namespace excluded for sake of space
public void Main()
var process = new LoadProcess();

Dts.TaskResult = (int)ScriptResults.Success;
catch (Exception ex)
Dts.TaskResult = (int)ScriptResults.Failure;

LoadProcess() is a class variable in another library. I wanted to make sure the code would run outside of the script task so I tried running it in a separate console application and it ran fine with the same DLLs.
I made sure the .NET framwork is set to 4.5 in properties (I also tried 4.5.1 and 4.5.2 and 4.6 to make sure), and ensured that my environment variables are shorter then the 2800 max length.

This is what the solutions explorer looks like in the script task:enter image description here

There are extra references in there in case the DLLs required them for some weird reason.

If you have any Idea what could be causing this error, please let me know because I have been stuck on it for a long time. Thank you for your time.

Answer Source

After a lot of testing I found that this error is caused due to the script component's inability to reach the DLL being referenced. The error: "Exception has been thrown by the target of an invocation" is thrown when one of the references in the script in unable to be found such as a file does not exist error or a library not found.

This is because the location of the script components is stored in a separate location than the actual solution of the SSIS package making the DLLs unreachable. I hope this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download