4

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

This is the package

Here it builds

This is the error on execution

Output

5
  • Can you post a picture of your SSIS project and also the full error description, please. Commented Mar 31, 2017 at 18:51
  • where did you put them? are you on shared drive or so (running in virtual machine) Commented Mar 31, 2017 at 18:55
  • It's not letting me upload pictures because I am new. Would be happy to e-mail them. Yes it is running on a VM. Commented Mar 31, 2017 at 19:04
  • 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. Commented Mar 31, 2017 at 21:21
  • 1
    Specifically was missing this: { [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute] public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase { Commented Mar 31, 2017 at 21:24

3 Answers 3

4

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.SSISScriptTaskEntr‌​yPointAttribute] 
public partial class ScriptMain : 
Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectM‌​odelBase {
Sign up to request clarification or add additional context in comments.

3 Comments

you have to accept your answer so your question will be marked as answered even if this is your own answer
@Mathew Nelson The fix you mentioned is working fine. We have tried it and the C# code is not getting executed properly without any issues. Thanks.
Just to add here, I just found a case where the only difference between my scripts was the autogenerated namespace name. I had to create a new script task and copy the entire script (exactly) to the new task and then I was able to execute it. I have a feeling it was because the package was upgraded from an older version, but I can't be sure. But this answer helped me figure it out.
0

You may also be targeting the incorrect version of SQL Server. If the SSIS project is set to target SQL Server 2012 and it is deployed to SQL Server 2016 it fails with this error. Change the target version in the project properties to 2016 and redeploy.

Comments

0

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

http://www.macaalay.com/2017/01/26/cannot-load-script-for-execution-after-migrating-your-ssis-package-to-a-new-sql-server-version/

1 Comment

Include what action needs to be taken in the answer along with the link to avoid page not found issues in future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.