barkome
asked on
How to use a C# Console Application as part of SSIS C# Script Editor?
Hello I have a C# console application, and Im trying to have the script part of a SSIS C# script task component?
Has anybody come across this?
Has anybody come across this?
ASKER
I would actually prefer is to replicate the C# Console Application Script into a SSIS C# Script Task, rather than call a stand alone application
Well, assuming you have the source for the program, just create a script task, check that the language is set to C# and not VB, open the editor, and start coding!
Seriously, though, what problems are you experiencing or expecting?
Mike
Seriously, though, what problems are you experiencing or expecting?
Mike
ASKER
Hello
I get the following error when trying to execute it as a SSIS C# script task:
at System.RuntimeMethodHandle .InvokeMet hod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeM ethodInfo. UnsafeInvo keInternal (Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeM ethodInfo. Invoke(Obj ect obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeM ember(Stri ng name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.SqlServer.Dts.Ta sks.Script Task.VSTAT askScripti ngEngine.E xecuteScri pt()
The C# script is:
I get the following error when trying to execute it as a SSIS C# script task:
at System.RuntimeMethodHandle
at System.Reflection.RuntimeM
at System.Reflection.RuntimeM
at System.RuntimeType.InvokeM
at Microsoft.SqlServer.Dts.Ta
The C# script is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.IO;
using Aspose.Cells;
namespace Aspose.Cells
{
class Program
{
static void Main(string[] args)
{
List<DataTable> dtList = new List<DataTable>();
var dirInfo = new DirectoryInfo("C:/test");
//Check if directory exists
if (dirInfo.Exists)
{
FileInfo[] files = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);
foreach (FileInfo file in files)
{
Workbook book = new Workbook(file.FullName);
foreach (Worksheet sheet in book.Worksheets)
{
//Check if worksheet as any data to be exported
if (sheet.Cells.MaxDataRow != -1)
{
dtList.Add(sheet.Cells.ExportDataTable(0, 0, sheet.Cells.MaxDataRow, sheet.Cells.MaxDataColumn));
}
}
}
}
}
}
}
Hi!,
I suspect you may be trying to use things that SSIS already provides, and confusing it! You might want to look at this article from MS, There are several other resources online from SimpleTalk and CodeProject that also guide you through similar problems. BTW, whereabouts in the code did it die?
Mike
I suspect you may be trying to use things that SSIS already provides, and confusing it! You might want to look at this article from MS, There are several other resources online from SimpleTalk and CodeProject that also guide you through similar problems. BTW, whereabouts in the code did it die?
Mike
ASKER
Its runs fine, and gives me the desired output when using VS C# Console Application, but failed out-rightly when its inside the C# script task.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hth
Mike