This document is archived and information here might be outdated.  Recommended version.


Get Extension Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Get Extension Snippet

Get an ArcGIS extension by specifying it's CLSID or ProgID.

[C#]
///<summary>Get an ArcGIS extension by specifying it's CLSID or ProgID</summary>
///
///<param name="application">An IApplication interface.</param>
///<param name="extensionName">A System.String that is the CLSID or ProgID for the ArcGIS extension to be returned. Example: "esriGeoStatisticalAnalystUI.GAExtension" or "{DE0502C4-8D34-11D3-A63A-0008C7BF3347}"</param>
/// 
///<returns>An IExtension interface that is the entension to be returned from it's CLSID or ProgID.</returns>
/// 
///<remarks>A listing of available ArcGIS extensions CLSID and ProgID values can be found at: http://edndoc.esri.com/arcobjects/9.1/default.asp?URL=/arcobjects/9.1/ArcGISDevHelp/TechnicalDocuments/Guids/ESRIExtIds.htm</remarks>
public ESRI.ArcGIS.esriSystem.IExtension GetExtension(ESRI.ArcGIS.Framework.IApplication application, System.String extensionName)
{
  
  if(application == null || extensionName == "")
  {
    return null;
  }
  ESRI.ArcGIS.esriSystem.UID extensionID=new ESRI.ArcGIS.esriSystem.UIDClass();
  extensionID.Value=extensionName; // example: "esriPublisherUI.Publisher"; 

  return application.FindExtensionByCLSID(extensionID);
}
[Visual Basic .NET]
'''<summary>Get an ArcGIS extension by specifying it's CLSID or ProgID</summary>
'''
'''<param name="application">An IApplication interface.</param>
'''<param name="extensionName">A System.String that is the CLSID or ProgID for the ArcGIS extension to be returned. Example: "esriGeoStatisticalAnalystUI.GAExtension" or "{DE0502C4-8D34-11D3-A63A-0008C7BF3347}"</param>
''' 
'''<returns>An IExtension interface that is the entension to be returned from it's CLSID or ProgID.</returns>
''' 
'''<remarks>A listing of available ArcGIS extensions CLSID and ProgID values can be found at: http://edndoc.esri.com/arcobjects/9.1/default.asp?URL=/arcobjects/9.1/ArcGISDevHelp/TechnicalDocuments/Guids/ESRIExtIds.htm</remarks>
Public Function GetExtension(ByVal application As ESRI.ArcGIS.Framework.IApplication, ByVal extensionName As System.String) As ESRI.ArcGIS.esriSystem.IExtension

  If application Is Nothing OrElse extensionName="" Then
    Return Nothing
  End If

  Dim extensionID As ESRI.ArcGIS.esriSystem.UID=New ESRI.ArcGIS.esriSystem.UIDClass
  extensionID.Value=extensionName ' example: "esriPublisherUI.Publisher";

  Return application.FindExtensionByCLSID(extensionID)

End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Framework
  • ESRI.ArcGIS.System