PC Review


Reply
Thread Tools Rate Thread

Catching events in a COM Add-in

 
 
Troels Grosbøll-Poulsen
Guest
Posts: n/a
 
      13th May 2004
Hello

I have made a COM Add-in in Visual Studio .NET 2003 by using a standard
shared Add-in project. The Add-in is for MS Project, and I have managed to
add a menu point to the MSP menu. However I can not catch the click event
for the commandBarControl!
I can not cast the application object I have in the OnConnection sub from
the type System.__COMObject to the type EnvDTE.DTE using CType; I get an
InvalidCastException. My code can be seen in the bottom of this mail.
What am I doing wrong? Why does the OnConnection sub not have an application
object of type EnvDTE.DTE which I can use to catch the click event?

Troels Grosbøll-Poulsen

--

Imports Microsoft.Office.Core
Imports EnvDTE
Imports Extensibility
Imports System.Runtime.InteropServices

<GuidAttribute("C7E1314D-89FA-48C5-B48C-1B6BD6D68172"),
ProgIdAttribute("MSProjectIntegration.Connect")> _
Public Class Connect

Implements IDTExtensibility2

Dim applicationObject As EnvDTE.DTE
<System.ContextStatic()> Public WithEvents commandBarEvents As
EnvDTE.CommandBarEvents
....
Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array)
Implements IDTExtensibility2.OnConnection
....
Try
applicationObject = CType(application, EnvDTE.DTE)
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString())
End Try
....
End Sub
....
End Class


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Catching Events Just close your eyes and see Microsoft C# .NET 3 17th Dec 2007 12:06 PM
catching Events Jeffrey Microsoft C# .NET 0 18th Jul 2005 05:25 PM
Catching Events Mike Microsoft VB .NET 3 6th Apr 2004 11:09 AM
Catching events outside my app MC Microsoft VB .NET 3 27th Mar 2004 05:41 PM
Catching events outside my app MC Microsoft Dot NET Framework 1 27th Mar 2004 03:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:03 PM.