Showing results for 
Search instead for 
Did you mean: 

Problems with UI in add-in c#

Valued Contributor
Valued Contributor



I have made simple add-in to SE. Registered it using cmd.exe and regasm. And i can see it in add-ins manager.Also i have implemented simple UI and AfterDocSaved event BUT i cant see my UI and event also doesn't work((


Here is my code.

namespace EdgeAddin





public class SolidEdgeAddinSmiley FrustratedolidEdgeFramework.ISolidEdgeAddIn, IDisposable


#region CATID

public const string CATID_SolidEdgeAddIn = "{26B1D2D1-2B03-11d2-B589-080036E8B802}";


public const string CATID_SEApplication = "{26618394-09D6-11d1-BA07-080036230602}";


public const string CATID_SEPart = "{26618396-09D6-11d1-BA07-080036230602}";


public const string CATID_SESyncPart = "{D9B0BB85-3A6C-4086-A0BB-88A1AAD57A58}";


public const string CATID_SEAssembly = "{26618395-09D6-11d1-BA07-080036230602}";


public const string CATID_SESyncAssembly = "{2C3C2A72-3A4A-471d-98B5-E3A8CFA4A2BF}";


public const string CATID_SESheetMetal = "{26618398-09D6-11D1-BA07-080036230602}";


public const string CATID_SESyncSheetMetal = "{9CBF2809-FF80-4dbc-98F2-B82DABF3530F}";


public const string CATID_SEDraft = "{08244193-B78D-11D2-9216-00C04F79BE98}";


public const string CATID_SEWeldment = "{7313526A-276F-11D4-B64E-00C04F79B2BF}";



private SolidEdgeFramework.AddIn m_addin;

private SolidEdgeFramework.Application m_application;

private SolidEdgeFramework.ISEApplicationEvents_Event m_appEvents;

private SolidEdgeFramework.SolidEdgeDocument m_document;

private SolidEdgeFramework.ISEDocumentEvents_Event docEvents;



public SolidEdgeAddin()




#region ISolidEdgeAddIn Members


public void OnConnectToEnvironment(string EnvCatID, object pEnvironmentDispatch, bool bFirstTime)




string[] commandNames = new string[5];

commandNames[0] = "cmdAbout\n\nAbout System\nAbout";

commandNames[1] = "cmdTester\n\nTester\nDebug";


int[] commandIDs = new int[5];

commandIDs[0] = 101;

commandIDs[1] = 102;


Array cmdid = commandIDs;

Array cmdname = commandNames;


//on every entry to enviroment (part/assembly/etc..) this func is called..

m_addin.SetAddInInfo(Marshal.GetHINSTANCE(this.GetType().Module).ToInt32(), EnvCatID, "ManagedMenu", 1, 2, 1, 2, commandIDs.Length,ref cmdid, ref cmdname);


if (bFirstTime)


SolidEdgeFramework.Environment env = (SolidEdgeFramework.Environment)pEnvironmentDispatch;

env.CommandBars.Add("ManagedMenu", SolidEdgeFramework.SeBarPosition.seBarTop, true, true);


m_addin.AddCommandBarButton(EnvCatID, "ManagedMenu", 101);

m_addin.AddCommandBarButton(EnvCatID, "ManagedMenu", 102);




// Get a reference to the application events

m_appEvents = (SolidEdgeFramework.ISEApplicationEvents_Event)m_application.ApplicationEvents;

m_appEvents.AfterDocumentSave += new ISEApplicationEvents_AfterDocumentSaveEventHandler(m_appEvents_AfterDocumentSave);







public void OnConnection(object Application, SolidEdgeFramework.SeConnectMode ConnectMode, SolidEdgeFramework.AddIn AddInInstance)



// Store local variables for later use


m_addin = AddInInstance;

m_application = (SolidEdgeFramework.Application)Application;


// Set Addin's GUI Version

AddInInstance.GuiVersion = 2;


AddInInstance.Visible = true;






public void OnDisconnection(SolidEdgeFramework.SeDisconnectMode DisconnectMode)


if (m_addin != null)



m_addin = null;


if (m_application != null)



m_application = null;







#region IDisposable Members


public void Dispose()


throw new NotImplementedException();





#region ComRegisrt


public static void RegisterFunction(Type t)





Microsoft.Win32.RegistryKey hkcr = Microsoft.Win32.Registry.ClassesRoot;


Microsoft.Win32.RegistryKey addinkey = hkcr.CreateSubKey("CLSID\\{" + t.GUID.ToString() + "}");


if (addinkey != null)



// Tell Edge to automatically connect to the add-in.


addinkey.SetValue("AutoConnect", 1);


// Set the description


addinkey.SetValue("409", "EdgeAddin");


// Set the summary


addinkey.SetValue("Summary", "Edge add-in");


/* Add the Microsoft standard "Implemented Categories" subkey and add ISolidEdgeAddIn as


* an implemented category. This is what allows Solid Edge to use the Windows registry


* APIs to find an addin registered on the machine.




addinkey.CreateSubKey("Implemented Categories\\" + CATID_SolidEdgeAddIn);


// Set the environment categories to indicate what environments the add-in should


// be connected to.


addinkey.CreateSubKey("Environment Categories\\" + CATID_SEApplication);


addinkey.CreateSubKey("Environment Categories\\" + CATID_SEPart);


addinkey.CreateSubKey("Environment Categories\\" + CATID_SEAssembly);


addinkey.CreateSubKey("Environment Categories\\" + CATID_SEDraft);










public static void UnregisterFunction(Type t)



Microsoft.Win32.RegistryKey hkcr = Microsoft.Win32.Registry.ClassesRoot;


hkcr.DeleteSubKey("CLSID\\{" + t.GUID.ToString() + "}");






#region Events

void m_appEvents_AfterDocumentSave(object theDocument)



//SolidEdgeFramework.Documents documents = null;

//SolidEdgePart.PartDocument part = null;

//documents = m_application.Documents;

//part = (SolidEdgePart.PartDocument)documents.Add("SolidEdge.PartDocument", Missing.Value);






Can anybody tell me what i did wrong? Why i cant see UI and event result?


Posted by: Walker
Post date: 5/28/2012 2:02:12 AM


Re: Problems with UI in add-in c#

Valued Contributor
Valued Contributor

Solved. All what is needed it's use /codebase with regasm.exe


Posted by: Walker
Post date: 5/28/2012 7:23:10 AM