AcceleratedDisplayLayers Group Initialization Exception

3035
1
Jump to solution
11-22-2013 09:33 AM
GeorgeFaraj
Occasional Contributor III
I am getting an "Object reference not set to an instance of an object." exception at
StackTrace "   at ESRI.ArcGIS.Client.DrawingSurface..ctor(Single dpi)\r\n   at 
                       ESRI.ArcGIS.Client.AcceleratedDisplayLayers.Initialize() string

as reported in the InitializationFailed handler for my AcceleratedDisplayLayers group.

A sample xaml is provided below. Basically the example below works perfectly fine when I move the local feature layer outside of the AcceleratedDisplayLayers group. If I keep it in the accelerated layers I get the exception.

It should also be noted that my base application is a WinForms app so I have my map in a WPF control that is hosted in my form using ElementHost. I can take the markup below and set it up in a new WPF application and it seems to work as is? Very strange... Hopefully someone else has run into this and has some insight!

Edit: I have now referenced the project containing the WPF control that is giving me the exception to my WPF test project and can load up the control just fine in a WPF window with no initialization exception. Accelerated layers support doesn't seem to like being hosted in a WinForm via ElementHost.


<Grid x:Name="LayoutRoot" Background="#FFE6E6E6" HorizontalAlignment="Stretch">   <Grid.Resources>             <esri:LocalFeatureService x:Key="FeatureService" Path="USCitiesStates.mpk" MaxRecords="30000" />        <esri:SimpleRenderer x:Key="MySimplePolygonRenderer">     <esri:SimpleRenderer.Symbol>      <esri:SimpleFillSymbol Fill="#440000FF" />     </esri:SimpleRenderer.Symbol>    </esri:SimpleRenderer>   </Grid.Resources>          <esri:Map  x:Name="arcMap" Background="#FFE3E3E3" MinimumResolution="0.1">             <esri:AcceleratedDisplayLayers InitializationFailed="AcceleratedDisplayLayers_InitializationFailed">                 <esri:ArcGISLocalFeatureLayer ID="States" Service="{StaticResource FeatureService}" LayerName="States" IsHitTestVisible="False"                         Renderer="{StaticResource MySimplePolygonRenderer}"                       OutFields="*"/>             </esri:AcceleratedDisplayLayers>         </esri:Map>   </Grid>
0 Kudos
1 Solution

Accepted Solutions
GeorgeFaraj
Occasional Contributor III
Aha, I found a solution on the forums once I used "elementhost" as a keyword.

http://forums.arcgis.com/threads/79379-Use-UseAcceleratedDisplay-true-with-ElementHost

I had to include PresentrationFramework, System.Xaml, and WindowsBase references in my forms project. I then added the following line as described in the above post.

new System.Windows.Application();

Cheers and Thanks Mike! Now I can stop banging my head against the wall :confused:

View solution in original post

1 Reply
GeorgeFaraj
Occasional Contributor III
Aha, I found a solution on the forums once I used "elementhost" as a keyword.

http://forums.arcgis.com/threads/79379-Use-UseAcceleratedDisplay-true-with-ElementHost

I had to include PresentrationFramework, System.Xaml, and WindowsBase references in my forms project. I then added the following line as described in the above post.

new System.Windows.Application();

Cheers and Thanks Mike! Now I can stop banging my head against the wall :confused: