简体   繁体   English

在 SSIS 中的 C# 脚本中抛出异常

[英]Exception has been thrown in C# Script in SSIS

I was warking in SSIS 2010 to make transfaring for my project from my pc to the server but i faced a problem with C# Script task it working in my pc very well but in the server it's give me an erro.我在 SSIS 2010 中徘徊,将我的项目从我的电脑转移到服务器,但我遇到了 C# 脚本任务的问题,它在我的电脑上运行得很好,但在服务器中它给了我一个错误。

This error when i execute the script我执行脚本时出现此错误

在此处输入图片说明

and that's the C# Script:这就是 C# 脚本:

#region Help:  Introduction to the script task
#endregion
#region Namespaces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System;// Basic Import Statement
using System.Collections.Generic; // Allows Us To Use Lists
using System.IO; // For File handles
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
#endregion
namespace ST_c47c0258ca4d4851b04d0fdb997749b9
{
    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {
        #region Help:  Using Integration Services variables and parameters in a script
        #endregion
        #region Help:  Firing Integration Services events from a script
        #endregion
        #region Help:  Using Integration Services connection managers in a script
        #endregion
        public void Main()
        {
            string inFolderName = @"\\SERVER\DWH File\SocialMedia\Source\Facebook\";
            string outFolderName = @"\\SERVER\DWH File\SocialMedia\Final Source\Facebook\";
            List<string> lines = new List<string>();
            string line;
            DirectoryInfo folder = new DirectoryInfo(inFolderName);//Assuming Test is your Folder
            FileInfo[] Files = folder.GetFiles("*.csv"); //Getting Text files

            using (var file = new System.IO.StreamReader(outFolderName + "Facebook Insights.csv"))
            {
                while ((line = file.ReadLine()) != null)
                {

                    lines.Add(line);

                }

            }
            foreach (FileInfo f in Files)
            {

                using (var file = new System.IO.StreamReader(f.FullName))
                {
                    while ((line = file.ReadLine()) != null)
                    {
                        if (line.Length == 0 || line.Contains("#") || line.ToLower().Contains("date") || line.ToLower().Contains("screen"))
                        {
                            continue;
                        }
                        else
                        {
                            lines.Add(line);
                        }
                    }
                    //System.IO.File.WriteAllLines(outFolderName + "TwtMentions.csv", lines.ToArray());
                }

                System.IO.File.WriteAllLines(outFolderName + "Facebook Insights.csv", lines.ToArray());
                File.Delete(f.FullName);
            }
            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
    }
}

my question where is the problem我的问题是哪里出了问题

I have a feeling it's probably your folder URIs.我有一种感觉,这可能是您的文件夹 URI。 When a package runs under your user ID, it uses your permissions, but when run from sql agent, you have to make sure it runs under the correct permissions so it will be allowed to access that network location.当一个包在您的用户 ID 下运行时,它会使用您的权限,但是当从 sql 代理运行时,您必须确保它在正确的权限下运行,以便允许它访问该网络位置。

See this:看到这个:

http://bi-polar23.blogspot.com/2007/12/ssis-and-sql-server-agent.html http://bi-polar23.blogspot.com/2007/12/ssis-and-sql-server-agent.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 调用的目标已引发异常(SSIS &amp; WinSCP &amp; C#) - Exception has been thrown by the target of an invocation (SSIS & WinSCP & C#) 通过SQL Server代理在SSIS包中运行的C#脚本有时会触发调用目标抛出的异常 - C# script run in SSIS package through SQL Server Agent sometimes triggers Exception has been thrown by the target of an invocation 调用的目标已引发异常 - SSIS 脚本任务错误 - Exception has been thrown by the target of an invocation - SSIS Script Task Error C#中的调用目标已引发异常 - Exception has been thrown by the target of an invocation in C# 目标调用引发了C#异常 - C# Exception has been thrown by the target of an invocation C#WPF中的调用目标已引发异常 - Exception has been thrown by the target of an invocation in C# WPF SSIS 脚本任务 Excel 连接打开:调用目标抛出异常 - SSIS Script Task Excel connection open: Exception has been thrown by the target of an invocation SSIS:调用目标已抛出错误异常 - SSIS: Error Exception has been thrown by the target of an invocation 在已部署的SSIS包中使用HtmlAgilityPack异常已被抛出 - HtmlAgilityPack exception has been thrown when used in deployed SSIS package SSIS 脚本任务获取“调用目标已抛出异常”。 使用第 3 方 dll 运行时 - SSIS Script Task getting "Exception has been thrown by the target of an invocation." when running with 3rd party dll
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM