<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Registration Code in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/registration-code/m-p/138632#M3576</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is a silly question that I hope someone can really answer: I have written an application that uses several (more than 20) custom commands and tools. They all work great but I noticed when I first started building them that they worked whether I included the following registration code or not - so I've left it out.&amp;nbsp; I have no intention of ever making any of these controls installable.&amp;nbsp; They exist solely for this program. Do I need this boilerplate or not?&amp;nbsp; Does anyone know the answer?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#region COM Registration Function(s)
[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(Type registerType)
{
&amp;nbsp; // Required for ArcGIS Component Category Registrar support
&amp;nbsp; ArcGISCategoryRegistration(registerType);
&amp;nbsp; //
&amp;nbsp; // TODO: Add any COM registration code here
&amp;nbsp; //
}

[ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(Type registerType)
{
&amp;nbsp; // Required for ArcGIS Component Category Registrar support
&amp;nbsp; ArcGISCategoryUnregistration(registerType);
&amp;nbsp; //
&amp;nbsp; // TODO: Add any COM unregistration code here
&amp;nbsp; //
}

/// &amp;lt;summary&amp;gt;
/// Required method for ArcGIS Component Category registration -
/// Do not modify the contents of this method with the code editor.
/// &amp;lt;/summary&amp;gt;
private static void ArcGISCategoryRegistration(Type registerType)
{
&amp;nbsp; string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
&amp;nbsp; ControlsCommands.Register(regKey);
}

/// &amp;lt;summary&amp;gt;
/// Required method for ArcGIS Component Category unregistration -
/// Do not modify the contents of this method with the code editor.
/// &amp;lt;/summary&amp;gt;
private static void ArcGISCategoryUnregistration(Type registerType)
{
&amp;nbsp; string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
&amp;nbsp; ControlsCommands.Unregister(regKey);
}
#endregion
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Nov 2011 21:26:57 GMT</pubDate>
    <dc:creator>GeorgeFaraj</dc:creator>
    <dc:date>2011-11-03T21:26:57Z</dc:date>
    <item>
      <title>Registration Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/registration-code/m-p/138632#M3576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is a silly question that I hope someone can really answer: I have written an application that uses several (more than 20) custom commands and tools. They all work great but I noticed when I first started building them that they worked whether I included the following registration code or not - so I've left it out.&amp;nbsp; I have no intention of ever making any of these controls installable.&amp;nbsp; They exist solely for this program. Do I need this boilerplate or not?&amp;nbsp; Does anyone know the answer?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#region COM Registration Function(s)
[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(Type registerType)
{
&amp;nbsp; // Required for ArcGIS Component Category Registrar support
&amp;nbsp; ArcGISCategoryRegistration(registerType);
&amp;nbsp; //
&amp;nbsp; // TODO: Add any COM registration code here
&amp;nbsp; //
}

[ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(Type registerType)
{
&amp;nbsp; // Required for ArcGIS Component Category Registrar support
&amp;nbsp; ArcGISCategoryUnregistration(registerType);
&amp;nbsp; //
&amp;nbsp; // TODO: Add any COM unregistration code here
&amp;nbsp; //
}

/// &amp;lt;summary&amp;gt;
/// Required method for ArcGIS Component Category registration -
/// Do not modify the contents of this method with the code editor.
/// &amp;lt;/summary&amp;gt;
private static void ArcGISCategoryRegistration(Type registerType)
{
&amp;nbsp; string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
&amp;nbsp; ControlsCommands.Register(regKey);
}

/// &amp;lt;summary&amp;gt;
/// Required method for ArcGIS Component Category unregistration -
/// Do not modify the contents of this method with the code editor.
/// &amp;lt;/summary&amp;gt;
private static void ArcGISCategoryUnregistration(Type registerType)
{
&amp;nbsp; string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
&amp;nbsp; ControlsCommands.Unregister(regKey);
}
#endregion
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2011 21:26:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/registration-code/m-p/138632#M3576</guid>
      <dc:creator>GeorgeFaraj</dc:creator>
      <dc:date>2011-11-03T21:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Registration Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/registration-code/m-p/138633#M3577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It depends on what you're doing.&amp;nbsp; The component categories exist so that ArcGIS can be made aware of the components they contain.&amp;nbsp; So, if you write a custom command/tool for ArcMap and you want it to go on a toolbar then you have to register it in the MxCommands component category.&amp;nbsp; However, if you wanted to execute that command from a button on a dialog (i.e. by creating a new instance of the command class and executing it via code) then it doesn't matter if it's registered in a component category or not.&amp;nbsp; The registration code you posted is for registering custom commands/tools for an ArcGIS Engine application.&amp;nbsp; If you want to put those commands/tools on the ESRI Toolbar Control then you will need to register them so that they are available for you to choose in the toolbar properties dialog.&amp;nbsp; If you're creating instances of the command/tool classes yourself via code and executing them or making them the current tool via code then you don't need to register them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2011 12:22:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/registration-code/m-p/138633#M3577</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2011-11-04T12:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Registration Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/registration-code/m-p/138634#M3578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you want to put those commands/tools on the ESRI Toolbar Control then you will need to register them so that they are available for you to choose in the toolbar properties dialog.&amp;nbsp; If you're creating instances of the command/tool classes yourself via code and executing them or making them the current tool via code then you don't need to register them.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Forgive my imprecision! That is kind of the point of my post. My program is a standalone viewer that will never use any external tools or commands - everything is wired directly in code. I am creating classes for the commands and tools (for example MyOwnUsefulTool class) and using them on an ArcGIS Engine Toolbar control by:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;toolsView.AddItem( new MyOwnUsefulTool( synchronizer ), 0, -1, false, 0, style ); &lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;They work fine without the registration code (as far as I can see.)&amp;nbsp; All the right places in the class are being called (OnCreate(), OnClick(), Enabled and so on.) Is there a hidden problem with doing this (memory leaks, null exceptions, COM errors, Demonic possession, or whatevah?) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll take the time to add them if they prevent problems but I'd rather not have the code if I don't need it. (I discovered by "mistake" that it worked without the code.)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2011 14:43:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/registration-code/m-p/138634#M3578</guid>
      <dc:creator>GeorgeFaraj</dc:creator>
      <dc:date>2011-11-04T14:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Registration Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/registration-code/m-p/138635#M3579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You should be fine.&amp;nbsp; The registration code is only used to register the classes in the component categories.&amp;nbsp; The component categories are how ArcGIS discovers what components are available.&amp;nbsp; Since you're handling the creation of your classes and are putting them on the toolbar yourself you don't need to put them into the component categories.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2011 16:18:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/registration-code/m-p/138635#M3579</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2011-11-04T16:18:24Z</dc:date>
    </item>
  </channel>
</rss>

