Author Topic: .NET Add-In not working correctly  (Read 7158 times)

tim-kilostar

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
.NET Add-In not working correctly
« on: December 20, 2004, 07:30:50 am »
Hi all -

I'm currently still evaluating EA 4.10.739, and in particular, I am looking at developing an addin using C#.

First, are addins supported in the trial edition? If not that might explain my problem!

The following code represents my addin:

Code: [Select]

using System;
using System.Runtime.InteropServices;

using EA;

namespace Plugin
{

#region IPlugin


public interface IPlugin

{


void EA_Connect(EA.Repository repository);


void EA_FileOpen(EA.Repository repository);


object EA_GetMenuItems(EA.Repository repository, string menuLocation, string menuName);


void EA_GetMenuState(EA.Repository repository, string menuLocation, string menuName, string itemName, ref bool isEnabled, ref bool isChecked);


void EA_MenuClick(EA.Repository repository, string menuLocation, string menuName, string itemName);


void EA_ShowHelp(EA.Repository repository, string menuLocation, string menuName, string itemName);


void EA_Disconnect();

}


#endregion


[System.Runtime.InteropServices.GuidAttribute( "21BF2AFD-8A39-43b1-B941-47F6DAA8F1F1" ),

System.Runtime.InteropServices.ComVisibleAttribute( true ),

System.Runtime.InteropServices.ClassInterfaceAttribute( ClassInterfaceType.None ) ]

public class Plugin :


Plugin.IPlugin

{


public Plugin()


{ }



public void EA_Connect(EA.Repository repository)


{


}



public void EA_Disconnect()


{



GC.Collect();



GC.WaitForPendingFinalizers();


}



public void EA_FileOpen(EA.Repository repository)


{


}



public object EA_GetMenuItems(EA.Repository repository, string menuLocation, string menuName)


{



if ( menuLocation == "MainMenu" )



{




if ( menuName == String.Empty )





return "-My &Plugin";




else if ( menuName == "-My &Plugin" )





return new string[] { "Hello", "World" };




else





return String.Empty;



}



else



{




return String.Empty;



}


}



public void EA_GetMenuState(EA.Repository repository, string menuLocation, string menuName, string itemName, ref bool isEnabled, ref bool isChecked)


{



isEnabled = true;


}



public void EA_MenuClick(EA.Repository repository, string menuLocation, string menuName, string itemName)


{


}



public void EA_ShowHelp(EA.Repository repository, string menuLocation, string menuName, string itemName)


{


}

}
}


Everything registers OK, and EA appears to load the addin. However, nothing will appear under the AddIn menu item in EA. Also, if I place a breakpoint in each of the methods, only EA_Disconnect() will ever get called. This is why I am wondering if AddIn's are not supported in the trial edition.

If this is not the case, then can anyone sport any problems with my code?? Any help would be gratefully appreciated.

Many thanks

- Tim

charge

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: .NET Add-In not working correctly
« Reply #1 on: December 20, 2004, 08:59:43 am »
addins are supported in the trial edition

Nick

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: .NET Add-In not working correctly
« Reply #2 on: January 31, 2005, 01:15:57 am »
Hi,

I had exactly the same problem when I upgraded from version 7.10.730 to the latest version.

The problem is, as you have spotted,  that the events are not firing.  When I roll back to the previous version of EA, everythisng is ok.

I am just about to file a bug reports.

Cheers

Nick :)

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: .NET Add-In not working correctly
« Reply #3 on: February 10, 2005, 08:45:10 am »
Tim,

I'm also working on C# add-ins and have had similar results, albeit with the registered version 4.51.744 (same thing seems to be the case with build 747).  I'd be interested in hearing how things turn out.

Cheers,
Fred Woolsey
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: .NET Add-In not working correctly
« Reply #4 on: February 10, 2005, 05:37:00 pm »
Hi Guys,

Does this thread help any?

http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=Automation;action=display;num=1097227460

I believe charge's solution of referencing interop.dll is on the money. Let us know if this does not resolve the problem.

Regards,
Ben

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: .NET Add-In not working correctly
« Reply #5 on: February 11, 2005, 07:32:31 am »
Cheers Ben,

BINGO!!! Works like a charm.  Once I get the some basic functionality (beyond showing up on the menu and responding to clicks), I'll post the code.  Thanks!

FCW
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: .NET Add-In not working correctly
« Reply #6 on: February 11, 2005, 07:41:46 am »
OK, so it doesn't do anything but respond to clicks by displaying a MessageBox, but I thought it might be useful to post the code anyway:

Code: [Select]
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using EA;

namespace EAHelper
{

/// <summary>

/// RegisterAddIn

/// </summary>

// Class interface EAHelperInterface

[Guid("EAA4976A-45C3-4BC5-BC0B-E474F4C3C83F")]

public interface EAHelperInterface

{


string EA_Connect(EA.Repository repository);


void EA_Disconnect();


void EA_FileOpen(EA.Repository repository);


string EA_GetMenuItems(EA.Repository repository, string menulocation, string menuname);


void EA_MenuClick(EA.Repository repository, string menuname, string menuitem);

}


// Events interface EAHelperEvents

[Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"),

InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]

public interface EAHelperEvents

{


}


// Class EAHelper

[Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"),

ClassInterface(ClassInterfaceType.None),

ComSourceInterfaces(typeof(EAHelperEvents))]

public class EAHelper : EAHelperInterface

{


public string EA_Connect(EA.Repository repository)


{



return null;


}



public void EA_Disconnect()


{


}



public void EA_FileOpen(EA.Repository repository)


{


}



public string EA_GetMenuItems(EA.Repository repository, string menulocation, string menuname)


{



return "&EAHelper";


}



public void EA_MenuClick(EA.Repository repository, string menuname, string menuitem)


{



System.Windows.Forms.MessageBox.Show("Add-In Menu Clicked");




}


}
}


Note also that the add-in is placed in the same directory as the EA executable, and registered with "regasm.exe".  I haven't experimented with placing the .dll elsewhere, but the .NET help makes some noises about requiring a strong name...not hard to do using "sn.exe", but I just haven't bothered trying it yet.  First things first...

Cheers,
Fred Woolsey
« Last Edit: February 11, 2005, 07:45:25 am by fwoolz »
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


lario

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: .NET Add-In not working correctly
« Reply #7 on: February 22, 2005, 11:37:58 am »
Your example is very helpful.  Could you take it a bit further and tell me how you registered the plugin with EA?

I am following the users guide 4.51 section 12.3.2.1.2.

What did u use for the ProjectName per step 5?
What did u use as the value per step 7?

Thanks for your help