cvbarbosa93 33845 - Friday, April 20, 2018 9:17 PM
Based on what you mention the script is doing I would guess that you are using the Office Interop assemblies - this being the case it would also mean you need to have a copy of Office installed on your server which is not supported - and would also require you to have a second license of office bought for each user that directly or indirectly uses that server.
Script Task Description: Exception has been thrown by the target of an invocation. - this will normally be
- missing dll/assembly
- incorrect dll/assembly version
- 32/64 bit issue
If it is just 32/64 bit issue then you can "fix" it by forcing dtexec to run in either 32/64 as applicable - most of the times you do wish to have it on 64 bit, even for excel - but if on your own PC 32 bit may be the requirement.
If it is a different issue you should first try and identify the correct error.
this can be done by using a try/catch block around your code and firing a event to log the error
try
{
Dts.Log("Rows processed: " + rowsProcessed.ToString(), 0, emptyBytes);
Dts.TaskResult = (int)ScriptResults.Success;
}
catch (Exception ex)
{
//An error occurred.
Dts.Events.FireError(0, "Script Task Example", ex.Message + "\r" + ex.StackTrace, String.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
https://docs.microsoft.com/en-us/sql/integration-services/extending-packages-scripting/task/raising-events-in-the-script-task?view=sql-server-2017 has more info on these.