I am getting an error message in VS studios when I try to execute a script task using C# code. The code opens in the editor and will build and rebuild successfully but when I run the package I get
"Cannot load script for execution".
Screenshots
I figured this out. When you create a new Script task in SSIS there is auto generated code in it that is critical for executing the task. If you take a fully working C# script from a Console application and just ctrl+a, ctrl+v over the entire contents of the SSIS Script task you lose critical parts of the script task code. When this happens, you are left with a script task that will open in the script editor and compile without generating any errors but it will not execute in SSIS.
Specifically was missing this:
{ [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain :
Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase {
Version difference of SQL Server was causing the issue for me. Resolved it by changing the SQL Server in deployemnt as mentioned in the below link
SSISproject and also the full error description, please.