AnsweredAssumed Answered

C# add-in shows up in plug-in list but does nothing

Question asked by Lukas Najman on Aug 18, 2016
Latest reply on Aug 19, 2016 by Lukas Najman



because of a problem VSTA macros stopped working after WIN10 Anniversary update, I have decided to rewrite all our macros to C# add-ins. I followed up AngelSix tutorial on writing some simple add-in just to make sure they will work. The sample code did not work as it was registering the add-in in


and not in


As my SW install is 64bit one, the add-in did not show up in available plugins. I rewrote the registering portion of the code and managed it to register itself into correct register, so it is displayed in the SW in available plugins. Problem is, the add-in, after enabling it does nothing. I guess there is still missing some step in the registration of the add-in or something?


For completeness, I am using Visual Studio 2015 Community to develop the plugin. I have both "Make assembly COM visible" and "Register for COM interop" options checked.


Here is the source code of the add-in.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swcommands;
using SolidWorks.Interop.swconst;
using SolidWorks.Interop.swpublished;
using SolidWorksTools;

namespace ClassLibrary1

    [SwAddin(Description ="MyAddin desc", Title ="My fisrt title")]
    public class SWFirstTestAddin : ISwAddin 


        private static void ComRegister(Type t)
            string keyPath = "SOFTWARE\\SolidWorks\\AddIns\\1fbff20b-cf23-40dc-949a-d89c3f9b74e0}";

            RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);

            RegistryKey rk = baseKey.CreateSubKey(keyPath);
            rk.SetValue(null, 1); // Load at startup
            rk.SetValue("Title", "My SwAddin"); // Title
            rk.SetValue("Description", "All your pixels are belong to us"); // Description

        private static void ComUnregister(Type t)
            RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
            RegistryKey rk = baseKey.OpenSubKey("SOFTWARE\\SolidWorks\\AddIns");

        public SldWorks mSwApplication;
        private int mSWCookie;

        private TaskpaneView mTaskPaneView;
        private SWTaskPaneHost mTaskPaneHost;

        public bool ConnectToSW(object ThisSW, int Cookie)
            mSwApplication = (SldWorks)ThisSW;
            mSWCookie = Cookie;

            //Set-up add-in callback function
            bool result = mSwApplication.SetAddinCallbackInfo2(0, this, Cookie);
            return true;

        public bool DisconnectFromSW()
            return true;         

        private void UISetup()
            mTaskPaneView = mSwApplication.CreateTaskpaneView2(String.Empty, "Magic task pane!");
            mTaskPaneHost = (SWTaskPaneHost)mTaskPaneView.AddControl(SWTaskPaneHost.SWTASKPANE_PROGID, "");

        private void UITeradown()
            mTaskPaneHost = null;
            mTaskPaneView = null;



Could you please help me to get the add-in working?