']]>' is not allowed in character data within ssis script task

2

I have a SSIS Script task that I am using inVS 2012 Integrated shell (SSDT-BI development) and I am running into an odd error.

Basically, my code kept crashing VS when I closed the Script Task editor. It prompted me with the error:

"Failure saving package. ']]>' is not allowed in character data. (Microsoft.SqlServer.ManagedDTS).

Is also gives me:

"Cannot show the editor for this task. Exception from HRESULT: 0x80131940 (Microsoft.SqlServerDTSRuntimeWrap)."

Then VS will crash and restart itself.

So judging by the error, it doesn't seem to link the string I am passing into a variable, which I was able to verify using the below code (which triggers the exact same error).

What am I missing here... is this a bug? I am sure I'm just blatantly missing a whitepaper or something on this subject but why can't the below code work in SSIS Script task? I know it would for a C# console app.

[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {
        public void Main()
        {
            // TODO: Add your code here
            string hi = "<![CDATA[" + "]]>";

            Dts.TaskResult = (int)ScriptResults.Success;
        }

        #region ScriptResults declaration
        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        };
        #endregion
    }
c#
sql-server
visual-studio
ssis
asked on Stack Overflow Feb 12, 2016 by S1r-Lanzelot • edited Feb 12, 2016 by S1r-Lanzelot

1 Answer

1

You can't use ]]> or < as the script code itself is saved as XML inside your package.

string hi = (char)60+"![CDATA[" + "]]"+ (char)62;
answered on Stack Overflow Feb 12, 2016 by Alex

User contributions licensed under CC BY-SA 3.0