[英]Exception has been thrown by the target of an invocation (SSIS & WinSCP & C#)
[英]Exception has been thrown in C# Script in SSIS
我在 SSIS 2010 中徘徊,將我的項目從我的電腦轉移到服務器,但我遇到了 C# 腳本任務的問題,它在我的電腦上運行得很好,但在服務器中它給了我一個錯誤。
我執行腳本時出現此錯誤
這就是 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
}
}
我的問題是哪里出了問題
我有一種感覺,這可能是您的文件夾 URI。 當一個包在您的用戶 ID 下運行時,它會使用您的權限,但是當從 sql 代理運行時,您必須確保它在正確的權限下運行,以便允許它訪問該網絡位置。
看到這個:
http://bi-polar23.blogspot.com/2007/12/ssis-and-sql-server-agent.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.