3 Replies Latest reply on Jul 4, 2018 3:44 AM by Alvaro Clemente

    Solid Works Addin Installer and registry

    Alvaro Clemente

      Hello!

       

      I've been working on an installer for my Addin using Visual Studio Setup Project. I've added the GUID on the registry view with the complete path (HKEY_LOCAL_MACHINE > SOFTWARE > SolidWorks > AddIn > {GUID}) set it to register always at install and unregister always at uninstall. I've also added the my main dll as an install and uninstall custom action and set its properties to Register : vsdraCOM but it still won't register the AddIn when I run the .msi. Am I missing something? How can I do to have this installer/uninstaller working with the registry? I need to deliver my addin to the rest of my corporation and they need a quick way to set it up and delete it since we are still developing and releasing quite regularly.

       

      Thanks a lot!

        • Re: Solid Works Addin Installer and registry
          Deepak Gupta

          Have you tried installing from the setup project within VS? Does that work?

           

          If not then we need to look at your project to find the issue.

          • Re: Solid Works Addin Installer and registry
            Alvaro Clemente

            Small Update:

             

            I've managed to make the installer install and uninstall the Addin via a installer class:

            using System;

            using System.Collections;

            using System.Collections.Generic;

            using System.ComponentModel;

            using System.Configuration.Install;

            using System.Linq;

            using System.Threading.Tasks;

             

            namespace SWAddin

            {

                [RunInstaller(true)]

                public partial class RegasmInstaller : Installer

                {

                    public RegasmInstaller()

                    {

                        InitializeComponent();

                    }

             

             

                    [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]

                    public override void Commit(System.Collections.IDictionary savedState)

                    {

                        base.Commit(savedState);

                        // Get the location of regasm 

                        string regasmPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + @"regasm.exe";

                        // NOTE: Needed because this is likely a 32 bit install program. 

                        regasmPath = regasmPath.Replace("Framework", "Framework64");

                        // Get the location of our DLL 

                        string componentPath = typeof(RegasmInstaller).Assembly.Location;

                        // Execute regasm 

                        System.Diagnostics.Process.Start(regasmPath, "/codebase \"" + componentPath + "\"");

                    }

             

             

                    [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]

                    public override void Install(System.Collections.IDictionary stateSaver)

                    {

                        base.Install(stateSaver);

                    }

             

             

                    [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]

                    public override void Uninstall(System.Collections.IDictionary stateSaver)

                    {

                        base.Uninstall(stateSaver);

             

             

                        // Get the location of regasm 

                        string regasmPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + @"regasm.exe";

                        regasmPath = regasmPath.Replace("Framework", "Framework64");

                        // Get the location of our DLL 

                        string componentPath = typeof(RegasmInstaller).Assembly.Location;

                        // Execute regasm 

                        System.Diagnostics.Process.Start(regasmPath, "/unregister \"" + componentPath + "\"");

                    }

                }

            }

             

            The code is reused from another post I found elsewhere, so it is not my own except maybe some minor modifications. The issue now is that it appears not to install other projects such as log4net, and the Taskpane shows completely empty (Not even empty to be fair, just transparent, instead of showing its content you can see what is behind it)

             

            Hopefully this is a helpfull update?