<?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 Loading widgets into a common Application domain in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/loading-widgets-into-a-common-application-domain/m-p/362801#M8538</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My flex viewer 2.2 application currently contains a number of Widgets that are managed by the Widget Manager. When the user clicks on a widget (e.g. a Helper widget), the Widget Manager loads the widget into a separate sibling application domain with the following line of code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; wgtInfo.load(null, null, null, moduleFactory); //wgtInfo = IModuleInfo&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I am unable to use the widget's variables and functions later on.&amp;nbsp; I attempt to find the Helper widget from the Widget Manager's list of widgets, and I do successfully.&amp;nbsp; But when I try to caste the Helper Widget from type IBaseWidget (the interface all widgets share) to type HelperWidget, I receive the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; TypeError: Error #1034: Type Coercion failed.....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is because the application domain of the class trying to use the Helper widget is different from the application domain of the Helper Widget.&amp;nbsp; I tried to fix this by loading all widgets into the same application domain as the loader:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; wgtInfo.load(ApplicationDomain.currentDomain, null, null, moduleFactory);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I now get the following error whenever I attempt to load the Helper widget:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; TypeError: Error #1009: Cannot access a property or method of a null object reference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I load my Helper widget into a common application domain that is accessible by the other widgets?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Apr 2011 16:10:41 GMT</pubDate>
    <dc:creator>KyleTraff</dc:creator>
    <dc:date>2011-04-28T16:10:41Z</dc:date>
    <item>
      <title>Loading widgets into a common Application domain</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/loading-widgets-into-a-common-application-domain/m-p/362801#M8538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My flex viewer 2.2 application currently contains a number of Widgets that are managed by the Widget Manager. When the user clicks on a widget (e.g. a Helper widget), the Widget Manager loads the widget into a separate sibling application domain with the following line of code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; wgtInfo.load(null, null, null, moduleFactory); //wgtInfo = IModuleInfo&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I am unable to use the widget's variables and functions later on.&amp;nbsp; I attempt to find the Helper widget from the Widget Manager's list of widgets, and I do successfully.&amp;nbsp; But when I try to caste the Helper Widget from type IBaseWidget (the interface all widgets share) to type HelperWidget, I receive the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; TypeError: Error #1034: Type Coercion failed.....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is because the application domain of the class trying to use the Helper widget is different from the application domain of the Helper Widget.&amp;nbsp; I tried to fix this by loading all widgets into the same application domain as the loader:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; wgtInfo.load(ApplicationDomain.currentDomain, null, null, moduleFactory);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I now get the following error whenever I attempt to load the Helper widget:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; TypeError: Error #1009: Cannot access a property or method of a null object reference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I load my Helper widget into a common application domain that is accessible by the other widgets?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2011 16:10:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/loading-widgets-into-a-common-application-domain/m-p/362801#M8538</guid>
      <dc:creator>KyleTraff</dc:creator>
      <dc:date>2011-04-28T16:10:41Z</dc:date>
    </item>
  </channel>
</rss>

