Author Topic: Broadcast Events  (Read 3322 times)

Eric Johannsen

  • EA User
  • **
  • Posts: 43
  • Karma: +0/-0
  • Model Driven Business[ch0174]
    • View Profile
Broadcast Events
« on: July 06, 2007, 01:20:22 am »
Hey all,

I have a nice little test plugin that works just fine - it's properly registered in COM and receives the addin events just fine.

Now I want to get it to receive broadcast events and decided to start by adding:

Code: [Select]

public void EA_FileOpen(EA.Repository rep)
{
   MessageBox.Show("Received the event.");
}


Unfortunately that method is never invoked.  What am I missing here?  How do I have to declare my method to receive the EA_FileOpen event?

Thanks!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Broadcast Events
« Reply #1 on: July 06, 2007, 02:08:33 am »
Eric,

Perhaps you have to have some kind of Implements clause here. Otherwise you have an appropriately named method, but have not explicitly told event publishers that this is anything other than a coincidence.

David
No, you can't have it!

Eric Johannsen

  • EA User
  • **
  • Posts: 43
  • Karma: +0/-0
  • Model Driven Business[ch0174]
    • View Profile
Re: Broadcast Events
« Reply #2 on: July 06, 2007, 11:28:50 am »
Turns out your answer is pretty darn close...

I forgot to expose that method for COM interop, so EA could not find it when querying the COM interface (which it does seem to do by naming convention).

Specifically I expose for COM interop using something like this:

Code: [Select]

[Guid("INSERT-YOUR-UNIQUE-GUID-HERE")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface _PluginGateway
{
   //
   // Addin events
   //
   [DispId(1)]
   string EA_Connect(EA.Repository rep);
   [DispId(2)]
   void EA_Disconnect();
   [DispId(3)]
   object EA_GetMenuItems(EA.Repository rep, string menuLoc, string menuName);
   [DispId(4)]
   object EA_GetMenuState(EA.Repository rep, string menuLoc, string menuName, string itemName, bool isEnabled, bool isChecked);
   [DispId(5)]
   void EA_MenuClick(EA.Repository rep, string menuLoc, string menuName, string itemName);
   [DispId(6)]
   void EA_OnOutputItemClicked(EA.Repository rep, string tabName, string lineText, long id);
   [DispId(7)]
   void EA_OnOutputItemDoubleClicked(EA.Repository rep, string tabName, string lineText, long id);
   [DispId(8)]
   void EA_ShowHelp(EA.Repository rep, string menuLoc, string menuName, string itemName);
   //
   // Broadcast Events
   //
   [DispId(9)]
   void EA_FileOpen(EA.Repository rep);
}

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Broadcast Events
« Reply #3 on: July 06, 2007, 11:38:16 am »
Yep...

I usually use VS 2005, and just tell the project that it will be visible to COM. Didn't think of the individual situation.

David
No, you can't have it!