Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am distributing an Addin for ArcGIS, and I love when you point the Addin manager to a folder, updates automatically get applied on the next restart. However, when you click on an Addin, it takes away this ability because it doesn't know where the source is.

In my Addin, I would like it to figure out if it is installed the shared way, or the double-click-on-the-file way. Then if it is installed in the double-click way, I can prompt the user if they would like to upgrade and show them the path to the upgrade.

It appears the Add-In manager knows where the Addin came from because it shows "My Add-ins" (which are from the double-click method) and the "Shared Add-Ins" (the add the folder method).

Anyone have any ideas which ArcObject this may be obtained or another round about way?

share|improve this question
add comment

1 Answer

I am not aware of an ArcObject interface or class that does this, but that would useful. And I don't have a complete answer for you question, but here is a suggestion that you might be able to build on.

I have an AddIn that has an Extension that checks the ArcMap "loaded" (ThisAddIn.Version) AddIn version with the version that I have deployed in a shared folder and then warns the user if they are different.

/// <summary>
/// Gets the add in version from the Addinfile
/// </summary>
/// <param name="path">The full path to an Esri AddIn file</param>
/// <returns>Add In Version</returns>
private static string GetAddInVersionFromFile(string path)
{
    string version = string.Empty;

    if (!File.Exists(path))
        throw new FileNotFoundException("AddInFile Not Found", path);

    ZipFile file = new ZipFile(path);

    foreach (var entry in file.Entries)
    {
        if (entry.FileName.Equals("config.xml", StringComparison.InvariantCultureIgnoreCase))
        {
            Stream stream = new MemoryStream();

            entry.Extract(stream);

            if (stream != null && stream.Length > 0)
            {
                string xmltext = string.Empty;

                stream.Position = 0;

                using (TextReader reader = new StreamReader(stream, Encoding.ASCII))
                {
                    xmltext = reader.ReadToEnd();
                }

                if (!string.IsNullOrEmpty(xmltext))
                {
                    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                    doc.LoadXml(xmltext);

                    version = (doc["ESRI.Configuration"]["Version"]).InnerText;

                    break;
                }
            }
        }
    }

    return version;
}

You could potentially build on this and check the registry folders HKEY_LOCAL_MACHINE\SOFTWARE\ESRI\Desktop10.0\Settings\AddInFolders and the AddInFolders.xml folder locations and look for your AddIn.

The ZipFile reference is Ionic.Zip.dll which I think is here: http://dotnetzip.codeplex.com/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.