I need to run an Execute Package Task
programmatically in code.
I get the following error:
Error in Microsoft.SqlServer.Dts.Runtime.TaskHost/ :
There is no project to reference.
Error in Microsoft.SqlServer.Dts.Runtime.TaskHost:
There were errors during task validation.
Failure
This error only occurs if I set the Execute Package Task
ReferenceType
to
Project Reference
.
However, if I set the ReferenceType
to External Reference
, the error does not occur and the packages are run successfully.
I need to know why this error occur and why can't I use Project Reference
?
The following screen shot shows the setting which cause the error:
The below setting does not cause an error:
Lastly here is my code which runs the task programmatically:
class Program
{
class MyEventListener : DefaultEvents
{
public override bool OnError(DtsObject source, int errorCode, string subComponent,
string description, string helpFile, int helpContext, string idofInterfaceWithError)
{
Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description);
return false;
}
}
static void Main(string[] args)
{
string pkgLocation;
Package pkg;
Application app;
DTSExecResult pkgResults;
MyEventListener eventListener = new MyEventListener();
pkgLocation =
@"C:\Users\Administrator\Desktop\ExampleConnectionMgr\Master.dtsx";
app = new Application();
pkg = app.LoadPackage(pkgLocation, eventListener);
pkgResults = pkg.Execute(null, null, eventListener, null, null);
Console.WriteLine(pkgResults.ToString());
Console.ReadKey();
}
}