Problem getting IComPropertyPage2 (EditorExtension) to register

3287
6
04-29-2013 09:25 AM
by Anonymous User
Not applicable
Original User: Steve Clark

This has been an on-going problem and decided to tackle it as I am recompiling the ArcGIS 10 code for Windows 7. I have a EditorExtension class that implements IComPropertyPage2 for the purpose of adding a tab to the EditorExtension which listens for whether the user wants to invoke the extension or not.

This is set up as an msi (for now) and when the tlb is added, the commands are registered and added properly. However, the EditorExtension is usually hit or miss and the workaround has sometimes been to go into Categories and click Category Importer. That usually works but now in Windows 7, I can't even do that. The object simply does not show up in ESRI Editor Extension.

The code is fairly old but wonder if something is fundamentally wrong or is there now a better way of doing this? How do I get it to consistently register the EditorExtension upon install?

    [Guid("8ED2FF58-AAD3-48fe-9A76-182D53D964B6")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("CSUEditorExtension.EditorPropertyPage")]
    public class EditorPropertyPage : ESRI.ArcGIS.Framework.IComPropertyPage2
    {
        public EditorPropertyPage()
        {
        }

        #region Class Variables
        private Boolean m_pageDirty;
        private IComPropertyPageSite m_propPageSite;
        private frmEditorExtension m_frmCSU;
        private CSU.ArcGIS.AddPtrInterface.AddPtrInterface m_CSUExtension;
        private const String m_sVersionEnabled = "Enabled";
        private const String m_sVersionDisabled = "Disabled";
        private const String m_CSUExtensionGUID = "{DEF7F6B1-B483-430D-970C-47C2E3398F5D}";
        #endregion

        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
        }

        #region ArcGIS Component Category Registrar generated code
        /// <summary>
        /// Required method for ArcGIS Component Category registration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryRegistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            EditorPropertyPages.Register(regKey);

        }
        /// <summary>
        /// Required method for ArcGIS Component Category unregistration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryUnregistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            EditorPropertyPages.Unregister(regKey);
        }

        #endregion
        #endregion
0 Kudos
6 Replies
by Anonymous User
Not applicable
Original User: rlwatson

You are running ESRIRegAsm on your assembly, right?

Calling it registers your assembly and produces an ecfg file in C:\Program Files (x86)\Common Files\ArcGIS\Desktop10.1\Configuration\CATID.  That file is a renamed zip file so you can look at the contents.

If you don't want to run ESRIRegAsm during installation then you can simply register the assembly yourself and install the ecfg file youyourself.  This is what we do.
0 Kudos
SteveClark
New Contributor III
For the few msi applications that I have left, I use the Installer class.

        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);
            RegistrationServices regSrv = new RegistrationServices();
            regSrv.RegisterAssembly(base.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase);
        }

        public override void Uninstall(System.Collections.IDictionary savedState)
        {
            base.Uninstall(savedState);
            RegistrationServices regSrv = new RegistrationServices();
            regSrv.UnregisterAssembly(base.GetType().Assembly);
        }

I know when a couple of other msi are run (with the same Installer class), Windows 7 pops up a message about ESRIregasm. There's something different about this that I can't see and I am hoping it's not about the EditorExtension itself.
0 Kudos
by Anonymous User
Not applicable
Original User: Neil

The way you register COM classes with the ESRI component categories has changed for 10.x.  The code you posted for your installer class is not correct.  Registration is now performed by the esriRegAsm utility.  You must change your installer class to call this utility or do as Richard suggested.  An updated installer class would look something like this:

Public Class Installer1

    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()

        'Add initialization code after the call to InitializeComponent

    End Sub

    Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        MyBase.Install(stateSaver)
    End Sub

    Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
        MyBase.Uninstall(savedState)
    End Sub

    Protected Overrides Sub OnAfterInstall(ByVal savedState As System.Collections.IDictionary)
        MyBase.OnAfterInstall(savedState)
        Try
            ' Call the ESRI RegAsm utility to register the assembly classes with the ESRI component categories.
            Dim commonFilesPath As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)
            Dim regAsmPath As String = System.IO.Path.Combine(commonFilesPath, "ArcGIS\bin\ESRIRegAsm.exe")
            Dim appPath As String = System.Reflection.Assembly.GetExecutingAssembly().Location
            Dim args As String = String.Format("""{0}"" /p:Desktop /s", appPath)
            Dim startInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo()
            startInfo.FileName = regAsmPath
            startInfo.Arguments = args
            Dim esriRegProcess As New Process
            esriRegProcess.StartInfo = startInfo
            esriRegProcess.Start()
            Do While Not esriRegProcess.HasExited

            Loop
        Catch ex As Exception
            MessageBox.Show(ex.Message, "LRMT Installer", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Protected Overrides Sub OnBeforeUninstall(ByVal savedState As System.Collections.IDictionary)
        MyBase.OnBeforeUninstall(savedState)
        Try
            ' Call the ESRI RegAsm utility to register the assembly classes with the ESRI component categories.
            Dim commonFilesPath As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)
            Dim regAsmPath As String = System.IO.Path.Combine(commonFilesPath, "ArcGIS\bin\ESRIRegAsm.exe")
            Dim appPath As String = System.Reflection.Assembly.GetExecutingAssembly().Location
            Dim args As String = String.Format("""{0}"" /p:Desktop /u /s", appPath)
            Dim startInfo As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo()
            startInfo.FileName = regAsmPath
            startInfo.Arguments = args
            Dim esriRegProcess As New Process
            esriRegProcess.StartInfo = startInfo
            esriRegProcess.Start()
            Do While Not esriRegProcess.HasExited

            Loop
        Catch ex As Exception
            MessageBox.Show(ex.Message, "LRMT Installer", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

End Class
SteveClark
New Contributor III
Thank you, I had overlooked that. Maybe it's time to get my remaining enterprise applications converted over to Add-Ins.
0 Kudos
SteveClark
New Contributor III
Ok, I created the InvokeESRIRegAsm project, re-created the setup project in my application and all built successfully. However, when I go run the msi, the setup comes up with this error. I did a search but found nothing. This is ArcGIS 10.0 SP4 on Windows 7.

Error 1001. Exception occurred while initializing the installation. System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\SysW0W64\Files' or one of its dependencies. The system cannot find the file specified.
0 Kudos
by Anonymous User
Not applicable
Original User: Steve Clark

I discovered something: I made sure the RegAsm project, extension project and prerequisite and launch condition all have the same .Net framework (4.0 client profile), and I built for All CPU. Is this the right framework? But in running the msi, I am still getting that same error message. What does that relate to?
0 Kudos