Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help calling SSIS package from C#

Status
Not open for further replies.

fabjoe

Programmer
May 25, 2012
1
IT
Hi all, I've written a small winForm application to call a SSIS package with a configuration file.

In addition I've added a class EventListener inherited from DefaultEvents to log execution error.

Here you are application code:

string pkgLocation;
Package pkg;
Microsoft.SqlServer.Dts.Runtime.Application app;
DTSExecResult pkgResults;
MyEventListener eventListener = new MyEventListener();
pkgLocation = txtDTX.Text;

app = new Microsoft.SqlServer.Dts.Runtime.Application();
pkg = app.LoadPackage(pkgLocation, eventListener);
pkg.ImportConfigurationFile(txtConfig.Text);
pkgResults = pkg.Execute(null, null, eventListener,null,null);

and this is MyEventListener class

public class MyEventListener : DefaultEvents
{
public override bool OnError(DtsObject source, int errorCode, string subComponent,
string description, string helpFile, int helpContext, string idofInterfaceWithError)
{
StreamWriter oFile = new StreamWriter(ConfigurationManager.AppSettings["ErrorFile"],true);
oFile.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description);
oFile.Flush();
oFile.Close();
oFile.Dispose();
return false;
}
}

Running the application on a Windows Server 2008 R2 (64 bit) machine with SSIS 2012 installed (my code refers to Microsoft.SqlServer.ManagedDTS.dll version 11.0.2100.60)

the package fails and I took the following error on my EventListener: Error in Microsoft.SqlServer.Dts.Runtime.TaskHost/ : The Execute method on the task returned error code 0x80131621 (Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.). The Execute method must succeed, and indicate the result using an "out" parameter.

Can someone help me to investigate the problem?

Perhaps I need to use a different way instead of MyEventListener class?

Thank you in advance for your help.

Best regards

Fabrizio
 
add useLegacyV2RuntimeActivationPolicy="true" to the app.Config
CallSSIS05.jpg


More info [URL unfurl="true"]http://microsoft-ssis.blogspot.com/2012/09/call-ssis-2012-package-within-net.html[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top