11 Replies Latest reply on Mar 4, 2014 1:23 AM by Brant Williams

    Two AddIn Registry Questions

    Brant Williams

      Question 1: If you are removing an AddIn, what Registry entries should be deleted?

       

      The two primary entries made during Com Registration are:

      HKLM SOFTWARE\\SolidWorks\\Addins\\{" + t.GUID.ToString() + "}

      HKCU Software\\SolidWorks\\AddInsStartup\\{" + t.GUID.ToString() + "}

       

      But if you do a search on the GUID in the registry...you will find there are entries all over the place...most of them under the User Interface Sub Sections...  Do you try and chase down ALL the entries...or do you just let them sit there.

       

      Question 2: This question relates to the standard SwAddIn Template provided by the API SDK. When Solidworks starts, and your AddIn is set to load, SW creates an instance of the SwAddin object. In the base template, the SwAddin Class has some constants declared including mainItemID1 and mainItemID2.  These same constants are passed as a parameter to the AddCommandItem2 calls which set up 2 example command group items in the template.  When these command group items are added, is that when SW saves the IDs to the Registry?

       

      If you also examine the code in the AddCommandmgr() method, you will see that it compares the current IDs (the constants declared in the SwAddin Class...which will be passed to the AddCommandItem2 calls ) to IDs stored in the registry from previous sessions.  I have played around and confirmed that these IDs ARE the constants declared at the SwAddin class.  What is the point in all this?

       

      Thanks.  I am just trying to understand how this works.  There are a lot of things that seem to go on in the back ground that the SWorks Application instance does...than you can not really see. 


        • Re: Two AddIn Registry Questions
          Artem Taturevych

          You normally need to remove the add-in guid from the HKLM\Software\SolidWorks\Addin when uninstalling so it is not shown in the Addin Manager dialog in SolidWorks. It is also a good practice to remove the key from the HKCU\Software\SolidWorks\AddInsStartup but it really doesn't have too much influence.

           

          I never remove the keys under the UI sections because it may be risky. For example user can add custom buttons to your tab box, If not the box won't be shown after uninstall anyway.

           

          You may also find keys under the 'Classes Root' etc. This usually removed when you unregister you assembly/com server with the RegAsm or RegSvr32 utilities correspondingly.

           

          I have recorded the video where I'm talking about the add-in registration: http://www.youtube.com/watch?v=5Qy7KKy8-fE

           

          Regarding the second questions. All these ids compare routines are intended to identify whether the current command tab set equals to what user currently has. If it is the same - do not re-add the command tab or delete and rebuild the tab if it is different.

            • Re: Two AddIn Registry Questions
              Brant Williams

              Thank you for the clear explanation. 

               

              Those were the registry entries I deleted.  I left everything else alone.  You made a comment about "unregistering the assembly/com server with the RegAsm or RegSvr32 utilities"  I did not do that.  I deleted the project files and binaries after removing the registries.  If there any cleaning up I still need to do?

               

              Thanks again...

                • Re: Two AddIn Registry Questions
                  Artem Taturevych

                  Hi Brant,

                   

                  Yes, it is a good practice to unregister your add-in with register utility to remove all registry entries from ‘classes’ registry folders. Again it is not so critical if you do not do that. You will have a 'dead' registry keys which may be cleared with registry cleaner utilities later.

                   

                  If you are using .NET add-in (C# or VB.NET) you need to call the RegAsm utility with /u switch. If you are using COM based add-in (C++) you need to call RegSvr32 utility with /u switch. Here another document: https://forum.solidworks.com/docs/DOC-1463

                    • Re: Two AddIn Registry Questions
                      Brant Williams

                      Artem,

                       

                      Just to clarify details:

                      SW2013

                      .NET 4.0

                      C# (Basically the SDK AddIn template with the some code added to experiment with the API)

                       

                      The following settings were used for building/compiling:

                      Project/Application/Assembly Information dialogue box - Make assembly COM visible

                      Project/Build dialogue box - Register for COM interop

                      I did not manually register anything

                       

                      It builds and works fine, with one warning, which I have not been worrying about:

                      Registering an unsigned assembly with /codebase can cause your assembly to interfere with other applications that may be installed on the same computer. The /codebase switch is intended to be used only with signed assemblies. Please give your assembly a strong name and re-register it.

                       

                      As noted, when I removed the AddIn, I deleted the two entries noted:

                      HKEY_LOCAL_MACHINE\SOFTWARE\SolidWorks\AddIns\{fd751816-272b-48b9-8356-2b615614a8c5}

                      HKEY_CURRENT_USER\Software\SolidWorks\AddInsStartup\{fd751816-272b-48b9-8356-2b615614a8c5}

                       

                      I then deleted the entire Visual Studio project file, with binaries.  I then did a registry clearn with CCleaner...which did not seem to find anything AddIn related.

                       

                      1. Is there any other clean up I need to do?

                      2. Would I be better doing the manual registration process noted in your video?

                       

                      Thanks again...

                        • Re: Two AddIn Registry Questions
                          Artem Taturevych

                          If you look at 'Build Events' section of your add-in projects (under the project properties) you will find the call to regasm utility there with the /codebase and /tlb switches in the post build section. So it is similar to what I shown in my video with the only difference that it is embedded in the project so it is called every time you build it.

                           

                          So to summarise, when you build the project you compile the dll + add the registry keys (you may find it in your code - DllEntry point) + call regasm utility.

                            • Re: Two AddIn Registry Questions
                              Brant Williams

                              OK.....I see it here....in MS-DOS type scripting...

                               

                              IF EXIST "$(TargetDir)$(TargetName).bmp" (GOTO REGISTRATION)

                              XCOPY "$(ProjectDir)AddinIcon.bmp" "$(TargetDir)"  /F

                              REN "$(TargetDir)AddinIcon.bmp" "$(TargetName).bmp"

                               

                              :REGISTRATION

                              IF "$(TargetFrameworkVersion)"=="v4.0" GOTO NET40

                              IF "$(TargetFrameworkVersion)"=="v3.5" GOTO NET20

                              IF "$(TargetFrameworkVersion)"=="v3.0" GOTO NET20

                              IF "$(TargetFrameworkVersion)"=="v2.0" GOTO NET20

                              GOTO END

                               

                              :NET40

                              set FMWK="v4.0.30319"

                              GOTO REG

                               

                              :NET20

                              set FMWK="v2.0.50727"

                              GOTO REG

                               

                              :REG

                              IF "$(PlatformName)" == "AnyCPU" GOTO ANYCPU

                              IF "$(PlatformName)" == "x64" GOTO X64

                              GOTO END

                               

                              :ANYCPU

                              IF EXIST "%Windir%\Microsoft.NET\Framework64\%FMWK%\regasm.exe" "%Windir%\Microsoft.NET\Framework64\%FMWK%\regasm" /codebase "$(TargetPath)"

                              GOTO END

                               

                              :X64

                              IF EXIST "%Windir%\Microsoft.NET\Framework64\%FMWK%\regasm.exe" "%Windir%\Microsoft.NET\Framework64\%FMWK%\regasm" /codebase "$(TargetPath)"

                              GOTO END

                               

                              :END

                               

                              One last question, is there anything I need to clean up...since I just deleted the AddIn project files, binaries, and erased the Reg keys?

                              • Re: Two AddIn Registry Questions
                                Brant Williams

                                Artem,

                                 

                                If I deleted the dll's...is my only option to go to the registry. 

                                 

                                I believe that the registration information is typically located in HKEY_CLASSES_ROOT\CLSID\{MY GUID}

                                 

                                I saved the GUIDs....  Should I just delete those entries?