Wednesday, September 26, 2012

Error Loading Component

Error Loading Component

I'm converting a Silverlight 3 project to Silverlight 4. I recently got the project able to run, but I am running into problems instantiating a search window. VS threw the following error at me:

Microsoft JScript runtime error: Unhandled Error in Silverlight Application Set property 'System.Windows.FrameworkElement.Style' threw an exception. [Line: 242 Position: 46]   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)    at ESM.Visualization.SearchWindow.InitializeComponent()    at ESM.Visualization.SearchWindow..ctor(Map mapWindow, String addressServiceUrl, String projectServiceUrl)    at ESM.Visualization.MainPage.InstantiateSearchWindow()    at ESM.Visualization.MainPage.MapWindow_Progress(Object sender, ProgressEventArgs e)    at ESRI.ArcGIS.Client.Map.layersProgressHandler(Object sender, ProgressEventArgs args)    at ESRI.ArcGIS.Client.LayerCollection.layer_OnProgress(Object sender, ProgressEventArgs args)    at ESRI.ArcGIS.Client.Layer.ProgressHandler.Invoke(Object sender, ProgressEventArgs args)    at ESRI.ArcGIS.Client.Layer.OnProgress(Int32 progress)    at ESRI.ArcGIS.Client.DynamicLayer.bitmap_DownloadProgress(Object sender, DownloadProgressEventArgs e, Image img, EventHandler`1 onProgressEventHandler, Int32 id)    at ESRI.ArcGIS.Client.DynamicLayer.<>c__DisplayClass7.<getSourceComplete>b__4(Object sender, DownloadProgressEventArgs e)    at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)    at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName) 

I researched the error and tried re-installing Silverlight in accordance to this solution. But the error still occurred. I looked at this SO question, but my App.xaml is hardly 242 lines. Here's my MainPage.xaml at around line 242:

<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Grid.Row="2" VerticalAlignment="Bottom">             <esriToolkit:Navigation x:Name="MapNavigation" Margin="5" Map="{Binding ElementName=MapWindow}" Visibility="Collapsed"  />             <!--<esri:ScaleBar x:Name="MainScaleBar" Margin="5" MapUnit="DecimalDegrees" Foreground="Black"                  Map="{Binding ElementName=MapWindow}"                 DisplayUnit="Miles" Visibility="Visible" />--> </StackPanel> 

And here is the .xaml for the search window I am trying to instantiate (at around line 242):

<grid:AgDataGrid x:Name="grdAddressResults" Grid.Row="1" Grid.Column="0" ColumnsAutoWidth="True"                                  ShowTotals="False" FocusMode="Row" FocusedRowChanged="grdResults_FocusedRowChanged"                                  IsMultiSelect="False" Margin="0,10,0,0">                                 <grid:AgDataGrid.Columns>                                     <grid:AgDataGridColumn FieldName="Address" />                                     <grid:AgDataGridColumn FieldName="X" Visible="False" />                                     <grid:AgDataGridColumn FieldName="Y" Visible="False" />                                 </grid:AgDataGrid.Columns>                                 <grid:AgDataGrid.TotalSummary>                                     <grid:AgDataGridSummaryItem FieldName="Address" SummaryType="Count" Title="Matches Found" />                                 </grid:AgDataGrid.TotalSummary>                             </grid:AgDataGrid> 

Answers & Comments...

Answer: 1

The exception tells

Set property 'System.Windows.FrameworkElement.Style' threw an exception.

Though this is not in the code you displayed - but I am almost sure you will find something like this somewhere in your code:

<SomeControl Style="MyCoolStyle" ... /> 

where it should be:

<SomeControl Style="{StaticResource MyCoolStyle}" ... /> 
by : Spontifixushttp://stackoverflow.com/users/1521227




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog