Book a Demo

Author Topic: Trouble creating a new addin. EA can't find it  (Read 5198 times)

Oliver Chappell

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Trouble creating a new addin. EA can't find it
« on: January 21, 2011, 09:40:01 pm »
Hi Geert or anyone else who can help.

I've developed some really useful code by extending working Addin Demo code in c#. This code works fine. However I'm trying to write a completely separate Addin from scratch and I can't get it working.
I've created a class library using Vis Studio 8 and .net 2.0
I've set the assembly to be COM Visible
I've set it to register for COM interop
I've made it start EA and added EA to the reference path (this all seems to work as it starts EA fine)
I've added my .main entry point to the registry in the Sparxs Addin section (I'm sure this is correct as I had to do this for the working code before it worked).

Once EA is lauched I use Manage Addins and get the error message "Error - Missing" against my new add in.
I've tried to register the dll using regasm dllpath /codebase
I've tried to register with regsvr32 (gives error no entry point)

When I search the registry for my working addin, it has the sparxs entry AND a CLSID as if its an active x object. However my new Addin does not have a CLSID entry.

Does anyone know what step I have missed?

Thanks

Olly Chappell

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Trouble creating a new addin. EA can't find it
« Reply #1 on: January 21, 2011, 10:01:41 pm »
Oliver,

There must be an error in either the the registry, or the way it is registered.

- What does your registry key look like?
- Does it work when you build in VS (and have visual studio register it for you)
- Can you post a snippet of your addin class?

Geert

Oliver Chappell

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Trouble creating a new addin. EA can't find it
« Reply #2 on: January 21, 2011, 10:15:22 pm »
Hi Geert, thanks for the swift help!
Below  is the entire code just one short class

Here is the .reg file text
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins\EETestAddin2]
@="EETestAddin2.Main"
Which creates
(default) sz EETestAddin2.Main prefixed with the Ab Symbol
Identical to the other working entries for my other working addins

I can't get it working though visual studio either. I'm not sure how to get Visual studio to register it for me other than through the project setting I mentioned in the previous post. Maybe that's the problem?


using System;
using System.Windows.Forms;
using EA;

namespace EETestAddin2
{
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      public class Main
      {
            private bool m_ShowFullMenus = false;

            public String EA_Connect(EA.Repository Repository)
            {
                  // No special processing req'd
                  return "";
            }

            public void EA_ShowHelp(EA.Repository Repository, string Location, string MenuName, string ItemName)
            {
                  MessageBox.Show("Help for: " + MenuName + "/" + ItemName);
            }

            public object EA_GetMenuItems(EA.Repository Repository, string Location, string MenuName)
            {
                  /* nb example of out parameter:
                  object item;
                  EA.ObjectType t = Repository.GetTreeSelectedItem(out item);
                  EA.Package r = (EA.Package) item;
                  */

                  switch( MenuName )
                  {
                        case "":
                              return "-&Hello Everyone everywhere";
                case "-&Hello Everyone everywhere":
                              string[] ar = { "&Packages", "Packages and &Elements", "-", "Show All &Options" };
                              return ar;
                  }
                  return "";
            }

            bool IsProjectOpen(EA.Repository Repository)
            {
                  try
                  {
                        EA.Collection c = Repository.Models;
                        return true;
                  }
                  catch
                  {
                        return false;
                  }
            }

            public void EA_GetMenuState(EA.Repository Repository, string Location, string MenuName, string ItemName, ref bool IsEnabled, ref bool IsChecked)
            {
                  if( IsProjectOpen(Repository) )
                  {
                        if( ItemName == "Show All &Options" )
                              IsChecked = m_ShowFullMenus;
                        else if( ItemName == "Packages and &Elements")
                              IsEnabled = m_ShowFullMenus;
                  }
                  else
                        // If no open project, disable all menu options
                        IsEnabled = false;
            }

            public void EA_MenuClick(EA.Repository Repository, string Location, string MenuName, string ItemName)
            {
                  //frmModel f;
                  switch( ItemName )
                  {
                        case "Show All &Options":
                              m_ShowFullMenus = !m_ShowFullMenus;
                              break;
                        case "&Packages":
                              break;
                        case "Packages and &Elements":
                              break;
                  }
            }

            public void EA_Disconnect()  
            {
                  GC.Collect();  
                  GC.WaitForPendingFinalizers();  
            }

      }
}

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Trouble creating a new addin. EA can't find it
« Reply #3 on: January 21, 2011, 10:51:28 pm »
Oliver,

Is the projectname in VS also EETestAddin2?
I have for all my addin classes the following properties defined.
I'm not entriely sure that is necesarry, but it works this way.

Code: [Select]
namespace EANavigator
{


    [ComVisible(true)]
    [Guid("c72f24fb-cc0a-40c4-b241-5f35f3d11521")]
    [ClassInterface(ClassInterfaceType.AutoDual)]
    public class EANavigatorAddin

Geert

Oliver Chappell

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Trouble creating a new addin. EA can't find it
« Reply #4 on: January 21, 2011, 11:05:46 pm »
Geert
This is the guts of my properties file, seems similar.
The project name, namespace and dll all have the same name
EETestAddin2

but it looks as if those lines came from your c# code, mine are not there so I'll try addin them just before my namespace declaration

More thanks

Olly

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: ComVisible(true)]
[assembly: Guid("2dac15d2-bc4c-4148-bb6d-f6dad3a3853c")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Oliver Chappell

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Trouble creating a new addin. EA can't find it
« Reply #5 on: January 21, 2011, 11:11:19 pm »
Geert
Which file in the project did you get    
   [ComVisible(true)]
   [Guid("c72f24fb-cc0a-40c4-b241-5f35f3d11521")]
   [ClassInterface(ClassInterfaceType.AutoDual)]
from?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Trouble creating a new addin. EA can't find it
« Reply #6 on: January 22, 2011, 12:48:18 am »
In the class definition file, right above the class declaration, so right after the namespace declaration.

Geert
« Last Edit: January 22, 2011, 12:50:02 am by Geert.Bellekens »