.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error installing Addin

1 REPLY 1
Reply
Message 1 of 2
FRPT1257
230 Views, 1 Reply

Error installing Addin

I created an Setup project to install my AutoCAD Addin, based in your code

http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html?url=WS73099cc1...

"Develop Applications with VB.NET and C# / Distribute Your Application"

 

You can see my code below.

I get the following error in the installation

Capture.JPG

 

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.IO;
using System.Reflection;

using Microsoft.Win32;

using Autodesk.AutoCAD.DatabaseServices;


namespace eGrouWSAutoCADAddin
{
    [RunInstaller(true)]
    public partial class AddinInstaller : System.Configuration.Install.Installer
    {
        StreamWriter icl_installLog;

        public AddinInstaller()
        {
            InitializeComponent();
        }


        public override void Install(System.Collections.IDictionary stateSaver)
        {
            // Gets the parameter passed across in the CustomActionData.
            icl_installLog = new StreamWriter("_eGrouWSAutoCADAddInSetup.log");
            icl_installLog.AutoFlush = true;

            try
            {
                m_InstallAddin(stateSaver);
            }
            finally
            {
                icl_installLog.WriteLine("Ending edit of config file");
                icl_installLog.Close();
            }
        }

        public void m_InstallAddin(System.Collections.IDictionary stateSaver)
        {
            try
            {
                base.Install(stateSaver);
                
                // Get the AutoCAD Applications key
                string sProdKey = HostApplicationServices.Current.MachineRegistryProductRootKey;
                string sAppName = "eGrouWSAutoCADAddin";

                RegistryKey regAcadProdKey = Registry.CurrentUser.OpenSubKey(sProdKey);
                RegistryKey regAcadAppKey = regAcadProdKey.OpenSubKey("Applications", true);

                // Check to see if the "MyApp" key exists
                string[] subKeys = regAcadAppKey.GetSubKeyNames();
                foreach (string subKey in subKeys)
                {
                    // If the application is already registered, exit
                    if (subKey.Equals(sAppName))
                    {
                        regAcadAppKey.Close();
                        return;
                    }
                }

                // Get the location of this module
                string sAssemblyPath = Assembly.GetExecutingAssembly().Location;

                // Register the application
                RegistryKey regAppAddInKey = regAcadAppKey.CreateSubKey(sAppName);
                regAppAddInKey.SetValue("DESCRIPTION", sAppName, RegistryValueKind.String);
                regAppAddInKey.SetValue("LOADCTRLS", 14, RegistryValueKind.DWord);
                regAppAddInKey.SetValue("LOADER", sAssemblyPath, RegistryValueKind.String);
                regAppAddInKey.SetValue("MANAGED", 1, RegistryValueKind.DWord);

                regAcadAppKey.Close();
      
            }
            catch (InstallException ex)
            {
                throw new InstallException(ex.Message);
            }
            catch
            {
                throw new InstallException("Error installing addin!");
            }
        }

        
        public override void Uninstall(System.Collections.IDictionary stateSaver)
        {
            // Gets the parameter passed across in the CustomActionData.
            icl_installLog = new StreamWriter("eGrouWSAutoCADAddin.log");
            icl_installLog.AutoFlush = true;

            try
            {
                m_UninstallAddin(stateSaver);
            }
            finally
            {
                icl_installLog.WriteLine("Ending edit of config file");
                icl_installLog.Close();
            }
        }


        public void m_UninstallAddin(IDictionary savedState)
        {
            try
            {
                // Get the AutoCAD Applications key
                string sProdKey = HostApplicationServices.Current.MachineRegistryProductRootKey;
                string sAppName = "eGrouWSAutoCADAddin";

                RegistryKey regAcadProdKey = Registry.CurrentUser.OpenSubKey(sProdKey);
                RegistryKey regAcadAppKey = regAcadProdKey.OpenSubKey("Applications", true);

                // Delete the key for the application
                regAcadAppKey.DeleteSubKeyTree(sAppName);
                regAcadAppKey.Close();
            }
            catch
            {

            }

            base.Uninstall(savedState);
        }
    }
}

 

1 REPLY 1
Message 2 of 2
mzakiralam
in reply to: FRPT1257

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost