22 Replies Latest reply on Aug 28, 2018 10:07 PM by Liu Xubo

    SolidWorks Addin not loading

    Richard Lessard

      I am developping an addin for SolidWorks.  The addin is now in production for a few months and works well on all computers except mine (development computer).  It was working before, but developping the last release, it doesn't work anymore. 


      I can't find a decisive reason why it doesn't work anymore.  I moved the  development folder, but I also modified all the paths in the registry using regasm.exe.


      • I tried various version of my addin (registering, un-registering everytime with regasm.exe), including versions that are now in production (and working) on many other computers.
      • I cleared the registry related to the addin before re-registering it (using regedit).
      • I uninstalled and re-installed SW.
      • I tried to launch the addin in various ways (trough the addin manager, opening it with file open, etc.)


      The problem is that I can't figure way to get closer to the problem...

      • There is no error message, the addin just doesn't load
      • I tried to launch in development mode from Visual Studio, using breakpoints as early as possible in the code, but it doesn't reach the breakpoints.


      I am using Solidworks 2016 x64 / VisualStudio 2015 (VB.net)


      Anybody have some tips / solutions to help me?  Thanks!!!!!

        • Re: SolidWorks Addin not loading
          Dave Bear

          Hi Richard,

          This is an Add-in for SolidWorks right?

          In that case it's working exactly as it should, just like everything else in SolidWorks, it works when it wants too..........


          Just kidding



          • Re: SolidWorks Addin not loading
            Amen Allah Jlili

            only your code could tell us the problem. There are no fortunate tellers amongst us!

              • Re: SolidWorks Addin not loading
                Richard Lessard

                The code have thousands of lines since the addin have been working for many versions without any problem (and still works on all machines except mine). 


                No changes have been made to the <ComRegisterFunction()> or the ConnectToSW or any function that loads the addin.  Those loading function are basically the same than the addin that comes with the Solidworks SDK kit.


                If you suspect a specific part of the code, please tell me and I will be happy to post it!



              • Re: SolidWorks Addin not loading
                Ivana Kolin

                1. What do you mean with doesn't load? Can you see it by add-ins and you can't check it or you doesn't see it at all?

                1.1. In case that you see it, is the path correct?

                1.2. In case that you don't see it at all:

                1.2.1. Windows version?

                1.2.2. is this your regasm command?

                     C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe /codebase "your.dll"

                1.2.3.. Are you running it as admin?


                2. Are you local admin?

                3. Do you know Process Monitor ?

                  • Re: SolidWorks Addin not loading
                    Richard Lessard

                    1. I can see it in the addins list in SW, but it doesn't start when I check it.

                    1.1. The path is correct

                    1.2.1  Windows 10

                    1.2.2  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm "your.dll" /codebase

                             ( your.dll and \codebase are inverted from your answer but I think it's the correct way to do it)

                    1.2.3 Yes, I run it as admin


                    2.  Yes I am local admin

                    3. I don't know process monitor, I look into it tomorrow morning and I come back to you if I could get closer to my problem with it..  If you have tips about it, they are welcome.

                  • Re: SolidWorks Addin not loading
                    Amen Allah Jlili

                    Can you paste your com register function. I think that's where the problem is.

                      • Re: SolidWorks Addin not loading
                        Richard Lessard

                        <ComRegisterFunction()> Public Shared Sub RegisterFunction(ByVal t As Type)



                                ' Get Custom Attribute: SwAddinAttribute

                                Dim attributes() As Object

                                Dim SWattr As SwAddinAttribute = Nothing



                                attributes = System.Attribute.GetCustomAttributes(GetType(SwAddin), GetType(SwAddinAttribute))



                                If attributes.Length > 0 Then

                                    SWattr = DirectCast(attributes(0), SwAddinAttribute)

                                End If


                                    Dim hklm As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine

                                    Dim hkcu As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser



                                    Dim keyname As String = "SOFTWARE\SolidWorks\Addins\{" + t.GUID.ToString() + "}"

                                    Dim addinkey As Microsoft.Win32.RegistryKey = hklm.CreateSubKey(keyname)

                                    addinkey.SetValue(Nothing, 0)

                                    addinkey.SetValue("Description", SWattr.Description)

                                    addinkey.SetValue("Title", SWattr.Title)



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

                                    addinkey = hkcu.CreateSubKey(keyname)

                                    addinkey.SetValue(Nothing, SWattr.LoadAtStartup, Microsoft.Win32.RegistryValueKind.DWord)

                                Catch nl As System.NullReferenceException

                                    Console.WriteLine("There was a problem registering this dll: SWattr is null.\n " & nl.Message)

                                    System.Windows.Forms.MessageBox.Show("There was a problem registering this dll: SWattr is null.\n" & nl.Message)

                                Catch e As System.Exception

                                    Console.WriteLine("There was a problem registering this dll: " & e.Message)

                                    System.Windows.Forms.MessageBox.Show("There was a problem registering this dll: " & e.Message)

                                End Try

                            End Sub

                      • Re: SolidWorks Addin not loading
                        Amen Allah Jlili

                        Are you running VS as an admin?

                        • Re: SolidWorks Addin not loading
                          Richard Lessard

                          Yes.  I run everything as admin. 


                          I saw your previous answer, you can look at this post for the microsoft.win32 framework : .net - Why is there no Microsoft.Win64 Namespace? - Stack Overflow

                          • Re: SolidWorks Addin not loading
                            Richard Lessard

                            Little update....

                            • I tried doing a clean re-install of SW, it did not change a thing.
                            • No error message appear when I check the addin boxes in the addin window.  However, I found out that by doing file->open on the addin.dll, the error message "Unable to initialize the Add-In component" appears.
                            • I tried to load various previous versions of my addin (all working on other computers) without any success (they all behave the same way)
                            • I tried to catch some events from my addin using Process Monitor  has suggested by Ivana Kolin and explained in this post without any success.  I didn't succeed to see anything.  Or I don't know how to use this tool, or the addin is not caught by the process monitor.


                            It was working before, so I probably screwed something in my computer (registry, references, something).  They are all valid possibilities since I played in the registry and references developping other plugins since the last release.


                            Therefore I see 2 path for the resolution.

                            • Find a tool that gets me closer to the problem and solve it
                            • Find a way to bring my computer back to it's state previous to the problem.
                              • My problem on this resolution path is that I did not develop on this addin for 2-3 months because I was working on other projects... so the state previous to the problem is something like 2-3 months old and I don't have restauration points that old.  I could re-install windows and everything, but I find it kind of an extreme and time consuming solution.


                            Any help will be appreciated since I am a little bit lost here.  Thank!!!