Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / July 2005

Tip: Looking for answers? Try searching our database.

Package Build Events

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Skelton - 20 Jul 2005 18:42 GMT
Hello, for the life of me I can't get the build events (OnBuildBegin,
OnBuildDone, etc) to work in my package.

In my Package Initialize method I put the code show below.  The code
executes fine but when I run the package and build a project it doesn't hit
the methods I wired up.  Can't find any examples of using build events with
packages in the VSIP docs or samples.

(within the Initialize method)
 DTE dte = (DTE)GetService(typeof(DTE));
 dte.Events.BuildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;

(method wired above)
void BuildEvents_OnBuildBegin(vsBuildScope Scope, vsBuildAction Action)
{
  Debug.WriteLine("BuildEvents_OnBuildBegin");
}
"Gary Chang[MSFT]" - 21 Jul 2005 11:21 GMT
Hi Paul,

Currently I am performing some tests on this issue. We will update you as
soon as we get anything out.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary Chang[MSFT]" - 22 Jul 2005 09:45 GMT
Hi Paul,

Based on your sample code, the events would connect up correctly, but what
happened then is the BuildEvents handler
is local to the Initialize function. When the function exits, the
BuildEvents handler is marked for deletion, and eventually it would be
garbage collected.  

So you need to define the BuildEvents objects in the package's class level,
such as the following code:
..
public class YourVSPkg : MSVSIP.Helper.Package
{
   ...
   public DTE dte;
   public Events evnts;
   public BuildEvents Buildevnts;
   ...
   protected override void Initialize()
   {
       dte = (DTE)GetService(typeof(DTE));
       evnts= (Events)dte.Events;
       Buildevnts = evnts.BuildEvents;
       Buildevnts.OnBuildBegin+=new
_dispBuildEvents_OnBuildBeginEventHandler(BuildEvents_OnBuildBegin);
       ...
       base.Initialize();
   }
..

By the way, I tested the above code in the VS2003 IDE, if you use the
VS2005, you need to used the Event2 interface and the new simplified syntax
instead:)

Hope this helps!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
Paul Skelton - 22 Jul 2005 18:41 GMT
That did the trick.  Thanks!!!

> Hi Paul,
>
[quoted text clipped - 46 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
"Gary Chang[MSFT]" - 23 Jul 2005 03:30 GMT
Hi Paul, I am glad to help you on this issue, wish you have a nice weekend:)

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.