【问题标题】:Task has encountered an exception in user code. SSIS Script Task任务在用户代码中遇到异常。 SSIS 脚本任务
【发布时间】:2018-09-13 16:55:23
【问题描述】:

我有一个脚本任务,可以创建电子邮件并将其发送给不同的用户。 在 Visual Studio 中执行时,代码本身可以正常工作。

但是当这段代码放在脚本任务中时 - 它给了我一个错误:

我发现原因之一可能是脚本任务的“主要”入口点。但这已经默认设置了。

还阅读了可能需要对 Microsoft Header 或其他内容进行一些更改,但不确定是什么。

  #region Namespaces
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using System.Data.OleDb;
    using System.Runtime.InteropServices;
    using System.Net.Mail;
    using System.Data.SqlClient;
    using Microsoft.Office.Interop.Excel;
    using System.Security.Policy;
    #endregion

    namespace ST_ff2838a07b8b464fa4f787c388ad3857
    {
        /// <summary>
        /// ScriptMain is the entry point class of the script.  Do not change the name, attributes,
        /// or parent of this class.
        /// </summary>


   //Do I need to change something here???  

//[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
        {


            /// <summary>
            /// This method is called when this script task executes in the control flow.
            /// Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
            /// To open Help, press F1.
            /// </summary>
            public void Main(string[] args)
            {
                string UnderwriterName = "SELECT DISTINCT [Underwriter] FROM [ExcessRenewal].[dbo].[Renewals]";
                string connectionString =

【问题讨论】:

  • 你把这段代码复制进去了吗?命名空间不匹配。

标签: c# ssis script-task


【解决方案1】:

SSIS 正在寻找与项目关联的命名空间:

ST_......75700c1

但我认为你在上面复制了代码并且现在有不同的命名空间:

ST_ff2838a07b8b464fa4f787c388ad3857

只需将脚本中的名称空间替换为您的项目名称空间,我认为您就可以开始了。

【讨论】:

  • 我尝试将命名空间更改为 ST_f575df1df9704300ae9d3c0d975700c1,但尚未成功。
  • 重新开始一个新的脚本任务。粘贴到您的命名空间中,然后粘贴您的代码
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多