Cannot load script for execution.

hi 

 iam creating  the  sisi package  with in script task . script task   was  build successful .  but when i was executive the ssis packages vs 2012.

 it get  error :Cannot load script for execution..

 the code is 

/*
   Microsoft SQL Server Integration Services Script Task
   Write scripts using Microsoft Visual C# 2008.
   The ScriptMain is the entry point class of the script.
*/

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;



namespace ST_8cdbf584a74b48abb384d8f03cf42f4d.csproj
{
    
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {

        #region VSTA generated code
        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        };
        #endregion

        /*
The execution engine calls this method when the task executes.
To access the object model, use the Dts property. Connections, variables, events,
and logging features are available as members of the Dts property as shown in the following examples.

To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
To post a log entry, call Dts.Log("This is my log text", 999, null);
To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);

To use the connections collection use something like the following:
ConnectionManager cm = Dts.Connections.Add("OLEDB");
cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";

Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.

To open Help, press F1.
*/

        public void Main()
        {
            byte[] dataByte = null; String errInfo = "";
            try
            {
                String sDirectory = Dts.Variables["User::Directory"].Value.ToString();
                String CreatePartitionFileXMLA = sDirectory + "\\partitionssales20010701to20010731.XMLA";
                String ProcessPartitionFileXMLA = sDirectory + "\\partitionssales20010701to20010731.XMLA";
                // Create XMLA Script
                Dts.Variables["User::CreatePartitions"].Value = ReadFile(CreatePartitionFileXMLA, errInfo);
                if (errInfo.Length > 0)
                {
                    Dts.Log("Error while reading XMLA file: " + errInfo, 0, dataByte);
                    Dts.TaskResult = (int)ScriptResults.Failure;
                }
                //Process XMLA Script
                Dts.Variables["User::ProcessPartitions"].Value = ReadFile(ProcessPartitionFileXMLA, errInfo);
                if (errInfo.Length > 0)
                {
                    Dts.Log("Error while reading XMLA file: " + errInfo, 0, dataByte);
                    Dts.TaskResult = (int)ScriptResults.Failure;
                }
                Dts.TaskResult = (int)ScriptResults.Success;
            }
            catch (Exception ex)
            {
                Dts.Log("Error Message: " + ex.Message, 0, dataByte);
                Dts.TaskResult = (int)ScriptResults.Failure;
            }
        }

        public String ReadFile(String FilePath, String ErrInfo)
        {
            String strContents;
            StreamReader sReader;
            try
            {
                sReader = File.OpenText(FilePath);
                strContents = sReader.ReadToEnd();
                sReader.Close();
                return strContents;
            }
            catch (Exception e)
            {
                MessageBox.Show(ErrInfo);
                ErrInfo = e.Message;
                return "";
            }
        }
    }
}

 how to solve this issue

 pleasse help me..

 

February 13th, 2015 6:50pm

Is it a 2008 or 2012 package?
Free Windows Admin Tool Kit Click here and download it now
February 14th, 2015 1:17am

I suggest you search within this forum for clues, it really can be anything, see if this post helps https://social.msdn.microsoft.com/forums/sqlserver/en-US/fe3a1b27-f62c-401d-9681-23c6f197c36f/ssis-script-taks-error-cannot-load-script-for-execution
February 14th, 2015 1:27am

hi this  2012 packages .
Free Windows Admin Tool Kit Click here and download it now
February 15th, 2015 5:46am

Open the package outside the project. Then get to the Script Task, click on Edit Script, simply exit without doing any changes. Attempt to running it again. This can fix the script task.
February 15th, 2015 12:09pm

Hi sheshu0022,

Based on my research, the issue can be occurred due to something get corrupted in the script task. To fix this issue, please copy the code in the task, then rebuild the script task with the same code to test again.

The following similar thread is for your reference:
http://stackoverflow.com/questions/15165760/ssis-script-task-fails-on-server-with-error-cannot-load-script-for-execution

Thanks,
Katherine Xiong

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2015 3:24am

Hey, you found my question on SO from 2 years ago - I feel honored. Alas, I find myself in the same boat again with SSIS 2012, only this time around recreating the script task does nothing. Runs fine in BIDS, fails in SSIS. No solution yet. Don't you wish that someone at MS would have thought about giving us a more meaningful error message? I suspect a .Net framework version or other platform issue.
March 12th, 2015 9:36pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics