Thanx Much Gert! Never would have spent enough time to look at that had you
not mentioned it...
For everyone else's benefit (via the omniscient, immutable archive of
Google) here's what works (well):
// -- SNIP --
UCOMIConnectionPointContainer CnnctPtCont = (UCOMIConnectionPointContainer)
Pkg;
UCOMIConnectionPoint CnnctPt;
PackageEventsSink PES = new PackageEventsSink ();
Guid guid = new Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5"); // UUID of
PackageEvents Interface
CnnctPtCont.FindConnectionPoint(ref guid, out CnnctPt);
int iCookie;
CnnctPt.Advise(PES, out iCookie);
Pkg.Execute();
// -- END SNIP --
// Where PacakgeEventsSink is defined like so:
public class PackageEventsSink : Microsoft.SQLServer.DTSPkg.PackageEvents
{
public void OnStart(...);
public void OnError(...);
....
CJ
> This is a known problem, which I ran into a while ago. The problem is
caused
> by the fact that TLBIMP is generating a wrapper aseembly which generates a
> separate sink object for every event, even if those events all correspond
to
> the same source interface. DTS (and SQL-DMO) are COM servers that rely
that
> there being only one connection point per client (one sink object per
source
> interface).
> To avoid this, you could deal with connection points the "raw way" using
the
> various UCOM. interfaces defined in System.Runtime.InteropServices.
> Please reply only to the newsgroups.
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> You assume all risk for your use.
> Copyright ? SQLDev.Net 1991-2002 All rights reserved.
> > Hi All.
> > I've got a little app that I want to use to build some small, dynamic
DTS
> > Packages. I've got pretty much everything figured out under C# using
> basic
> > trial and error - except for events.
> > I'm doing something to the effect of:
> > Pkg.OnStart += new PackageEvents_OnStartEventHandler(OnStart);
> > Pkg.OnFinish += new PackageEvents_OnFinishEventHandler(OnFinish);
> > Pkg.OnError += new PackageEvents_OnErrorEventHandler(OnError);
> > Pkg.OnProgress += new PackageEvents_OnProgressEventHandler(OnProgress);
> > Pkg.OnQueryCancel += new
> > PackageEvents_OnQueryCancelEventHandler(OnQueryCancel);
> > ...
> > public static void OnStart(System.String strEventSource) { ...}
> > public static void OnFinish(System.String strEventSource) { ...}
> > ....
> > The odd thing is that whatever handler I happen to add first (in this
case
> > OnStart) is the only one to get called. If I put OnError or OnProgress
> > above "Pkg.OnStart += ..." then it will be the only one called.
> > Am I missing something here? So far the last couple "issues" I had
(like
> QI
> > being broke on Task.CustomTask) were fixed when I applied SQL2k-SP2.
> > But no luck with the events.
> > Thanx in advance for any and all input.
> > Regards,
> > CJ