none
Error: Cannot load script for execution. RRS feed

  • Question

  • Hi All,

    I am trying to extract header information(attributes) of a xml file using script  task in control flow tab in SSIS. This is VS 2008. The code was bulit successfully.

    /*
    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.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Windows.Forms;
    using System.Xml;
    namespace WindowsFormsApplication4
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    var ret = Read("\\\\aaa\\mypath\\Test2\\myfile.txt", System.Text.Encoding.UTF8,
    "TransactionTypeCode", "ServicerNumber", "LoanNumber", "ProcessingStatusCode");
    foreach (var kv in ret)
    System.Diagnostics.Trace.WriteLine(kv);
    foreach (var kv in ReadAll("\\\\aaa\\mypath\\Test2\\myfile.txt", System.Text.Encoding.UTF8))
    System.Diagnostics.Trace.WriteLine(kv);
    }
    Dictionary<string, string> Read(string path, Encoding e, params string[] names)
    {
    var ret = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
    foreach (var name in names) ret.Add(name, null);
    var xr = new XmlTextReader(new StreamReader(path, e));
    xr.MoveToContent();
    while (xr.Read())
    {
    if (xr.MoveToFirstAttribute())
    {
    do
    if (ret.ContainsKey(xr.LocalName))
    ret[xr.LocalName] = xr.Value;
    while (xr.MoveToNextAttribute());
    xr.MoveToElement();
    }
    }
    return ret;
    }
    IEnumerable<KeyValuePair<string, string>> ReadAll(string path, Encoding e)
    {
    var xr = new XmlTextReader(new StreamReader(path, e));
    xr.MoveToContent();
    while (xr.Read())
    {
    if (xr.MoveToFirstAttribute())
    {
    do yield return new KeyValuePair<string, string>(xr.LocalName, xr.Value);
    while (xr.MoveToNextAttribute());
    xr.MoveToElement();
    }
    }
    }
    }
    }

    But when I try to run the package I get the following error message.

    "Error: Cannot load script for execution.

    Task script task failed.

    Can anyone tell me how to fix this please? I am not very familiar with C# and someone else helped me to write this code.

     

    Thanks

     

     

    shamen


    Thursday, December 1, 2011 5:41 PM

Answers

All replies