How to create a addin with c#?

 

Hi,Jason,I created a addin using c# in VS2008, but thers is no Icon in SE, would you give me a new simple sample only for c#?

Maybe, you can give me a PPT to decribe the process of createing the c# addin solution.

By the way, how to using "SetAddinInofEX"?

Thank you very much!

 

Posted by: assassin 007
Post date: 11/18/2008 8:51:55 PM

4 REPLIES

RE: How to create a addin with c#?

 

Hi, Jason, would you help me to check this project? And add a command to it? Thanks!

 

using System;

using System.Collections.Generic;

using System.Text;

using SolidEdgeFramework;

using SolidEdgePart;

using System.Runtime.InteropServices;

using Microsoft.Win32;

using System.Reflection;

 

namespace ttt

{

 

    [GuidAttribute("E596FF7A-55E2-4ba5-9551-E27318FCE950"),ProgId("MyAddIn.Addin"),ComVisible(true)]

 

    public class tts : SolidEdgeFramework.ISolidEdgeAddIn

    {

        private SolidEdgeFramework.AddIn m_addin;

        private SolidEdgeFramework.Application m_application;

 

        #region ISolidEdgeAddIn ??

 

        void ISolidEdgeAddIn.OnConnectToEnvironment(string EnvCatID, object pEnvironmentDispatch, bool bFirstTime)

        {

            //throw new NotImplementedException();

            //m_addin.SetAddInInfo();

        }

 

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

        {

            //throw new NotImplementedException();

 

            m_application = Application as SolidEdgeFramework.Application;

            m_addin = AddInInstance;

 

            AddInInstance.GuiVersion = 1;

        }

 

        void ISolidEdgeAddIn.OnDisconnection(SeDisconnectMode DisconnectMode)

        {

            //throw new NotImplementedException();

 

            if (m_addin != null)

            {

                Marshal.ReleaseComObject(m_addin);

                m_addin = null;

            }

            if (m_application != null)

            {

                Marshal.ReleaseComObject(m_application);

                m_application = null;

            }

        }

 

        #endregion

 

        #region "Regasm.exe functions" // Called by Regasm.exe

        [ComRegisterFunctionAttribute()]

        static void RegisterServer(Type t)

        {

            RegistryKey baseKey = null;

            RegistryKey summaryKey = null;

            AssemblyTitleAttribute titleAttribute = null;

            AssemblyDescriptionAttribute descriptionAttribute = null;

 

            try

            {

                baseKey = Registry.ClassesRoot.CreateSubKey(@"CLSID\{" + t.GUID.ToString() + "}");

                if (baseKey != null)

                {

                    // Tell Solid Edge to automatically load your addin

                    baseKey.SetValue("AutoConnect", 1);

                    // Write title

                    if (t.Assembly.IsDefined(typeof(AssemblyTitleAttribute), true))

                    {

                        titleAttribute = (AssemblyTitleAttribute)AssemblyTitleAttribute.GetCustomAttribute(t.Assembly, typeof(AssemblyTitleAttribute));

                        baseKey.SetValue("409", "xxxxx"/*titleAttribute.Title*/);

                    }

                    // Write description

                    if (t.Assembly.IsDefined(typeof(AssemblyDescriptionAttribute), true))

                    {

                        descriptionAttribute = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(t.Assembly, typeof(AssemblyDescriptionAttribute));

                        summaryKey = baseKey.CreateSubKey("Summary");

                        summaryKey.SetValue("409", descriptionAttribute.Description);

                    }

                    // Write required registry entries for a Solid Edge Addin

                    // See secatids.h in C:\Program Files\Solid Edge VXX\SDK\include

                    // CATID_SolidEdgeAddIn

                    baseKey.CreateSubKey(@"Implemented Categories\{Categories\{26B1D2D1-2B03-11d2-B589-080036E8B802}");

                    // Specify the Environment Categories that you want you addin // to work in

                    // CATID_SEApplication

                    baseKey.CreateSubKey( @"Environment Categories\{26618394-09D6-11d1-BA07-080036230602}");

                    // CATID_SEPart

                    baseKey.CreateSubKey(@"Environment Categories\{26618396-09D6-11d1-BA07-080036230602}");

                }

            }

            catch { }

            finally

            {

                if (baseKey != null)

                {

                    baseKey.Close();

                }

                if (baseKey != null)

                {

                    baseKey.Close();

                }

            }

        }

 

        // Here we cleanup any registry values left from Regasm /u.

        [ComUnregisterFunctionAttribute()]

        static void UnregisterServer(Type t)

        {

            try

            {

                Registry.ClassesRoot.DeleteSubKeyTree(@"CLSID\{" + t.GUID.ToString() + "}");

            }

            catch { }

        }

        #endregion

    }

}

 

Posted by: assassin 007
Post date: 11/19/2008 3:05:37 PM

RE: How to create a addin with c#?

I register this dll using "regsvr32", but system tell me that there is no entry point.

 

Posted by: assassin 007
Post date: 11/19/2008 3:07:16 PM

RE: How to create a addin with c#?

 

You need to download the Developer Conference (2005) material and review it.  It has all of your answers.

 

http://www.jasonnewell.net/Downloads/tabid/63/Default.aspx

 

 

Posted by: Jason Newell
Post date: 11/19/2008 7:53:15 PM

RE: How to create a addin with c#?

 

Hi,Jason,thank you very much!

 

Posted by: assassin 007
Post date: 11/30/2008 7:04:11 PM