<?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 assembly registration problems in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/assembly-registration-problems/m-p/48840#M1246</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have been working on a project at work for the last 5 months and today an new error occurred.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Firstly the specs: it's a developed with VB .NET targeting .NET 3.5 and using ArcObjects 10.0 for ArcMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's a legacy project and I have ported it from .NET 2.0 and ArcObjects 9.2 (some code from &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;much&lt;/SPAN&gt;&lt;SPAN&gt; earlier)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyhow everything was going well, just ironing out a few final kinks at the end of the project when a build process started throwing errors:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;"Cannot register assembly "projectName.dll". Exception has been thrown by the target of an invocation."&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I ran ESRIRegAsm.exe&amp;nbsp; with /e it displays:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;"Managed Exception: The type initializer for 'projectName.className' threw an exception. ... Operation Failed 01EAFB18 or 006AFB18 or some other random code&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For diagnostic purposes I excluded the named class from the project but the same error was reported in another class, tried this trick again and the error repeats in another. (most likely the first type processed)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I did some research and found &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://forums.arcgis.com/threads/1162-Issue-with-ESRIRegAsm" rel="nofollow" target="_blank"&gt;http://forums.arcgis.com/threads/1162-Issue-with-ESRIRegAsm&lt;/A&gt;&lt;SPAN&gt; which lead me to examine the &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ComRegisterFunction(), ComVisibleAttribute(False)&amp;gt; _ &amp;nbsp;&amp;nbsp;&amp;nbsp; Public Shared Sub RegisterFunction(ByVal registerType As Type) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Required for ArcGIS Component Category Registrar support &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArcGISCategoryRegistration(registerType)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Add any COM registration code after the ArcGISCategoryRegistration() call&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EditTasks.Register(regKey)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;methods.&amp;nbsp; However they all look very boilerplate and automatically generated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One point to note is that everything was working fine (code/build/run) just 10 minutes earlier.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is anyone able to offer any advice?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Aug 2012 07:52:02 GMT</pubDate>
    <dc:creator>KellyThomas</dc:creator>
    <dc:date>2012-08-16T07:52:02Z</dc:date>
    <item>
      <title>assembly registration problems</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/assembly-registration-problems/m-p/48840#M1246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have been working on a project at work for the last 5 months and today an new error occurred.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Firstly the specs: it's a developed with VB .NET targeting .NET 3.5 and using ArcObjects 10.0 for ArcMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's a legacy project and I have ported it from .NET 2.0 and ArcObjects 9.2 (some code from &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;much&lt;/SPAN&gt;&lt;SPAN&gt; earlier)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyhow everything was going well, just ironing out a few final kinks at the end of the project when a build process started throwing errors:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;"Cannot register assembly "projectName.dll". Exception has been thrown by the target of an invocation."&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I ran ESRIRegAsm.exe&amp;nbsp; with /e it displays:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;"Managed Exception: The type initializer for 'projectName.className' threw an exception. ... Operation Failed 01EAFB18 or 006AFB18 or some other random code&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For diagnostic purposes I excluded the named class from the project but the same error was reported in another class, tried this trick again and the error repeats in another. (most likely the first type processed)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I did some research and found &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://forums.arcgis.com/threads/1162-Issue-with-ESRIRegAsm" rel="nofollow" target="_blank"&gt;http://forums.arcgis.com/threads/1162-Issue-with-ESRIRegAsm&lt;/A&gt;&lt;SPAN&gt; which lead me to examine the &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ComRegisterFunction(), ComVisibleAttribute(False)&amp;gt; _ &amp;nbsp;&amp;nbsp;&amp;nbsp; Public Shared Sub RegisterFunction(ByVal registerType As Type) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Required for ArcGIS Component Category Registrar support &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArcGISCategoryRegistration(registerType)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Add any COM registration code after the ArcGISCategoryRegistration() call&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EditTasks.Register(regKey)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;methods.&amp;nbsp; However they all look very boilerplate and automatically generated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One point to note is that everything was working fine (code/build/run) just 10 minutes earlier.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is anyone able to offer any advice?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 07:52:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/assembly-registration-problems/m-p/48840#M1246</guid>
      <dc:creator>KellyThomas</dc:creator>
      <dc:date>2012-08-16T07:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: assembly registration problems</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/assembly-registration-problems/m-p/48841#M1247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This issue has now been resolved.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem was not ArcObjects/ESRI related.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The projects had been converted from VB6 using the VB Migration Partner.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One quirk of VB Migration Partner is that:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; 1) it adds a static constructor to every class it converts &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; 3) these constructors call an empty method of its VisualBasic6_Support module&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; 2) these method calls force execution of the VisualBasic6_Support static constructor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; 4) the VisualBasic6_Support static constructor calls InitializeLibrary from one of the VB Migration Partner .dlls&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; 5) the default behaviour of InitializeLibrary includes scaning through all dlls found in the current directory&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For whatever reason this scan was throwing an unhandled exception causing the behaviour I described earlier.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However InitializeLibrary can be configured to skip this scan, and now everything is working as it should.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So it turned out that while the exception was being caused by the call to RegisterFunction, it was occurring due to code in the static constructor i.e. before the RegisterFunction code is executed.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Aug 2012 01:57:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/assembly-registration-problems/m-p/48841#M1247</guid>
      <dc:creator>KellyThomas</dc:creator>
      <dc:date>2012-08-22T01:57:50Z</dc:date>
    </item>
  </channel>
</rss>

