2012-09-26 45 views
1

我是一個Silverlight 3的項目轉換爲Silverlight的4我最近買了該項目能夠運行,但我遇到了一個實例化搜索窗口的問題。 VS拋出下面的錯誤我:錯誤加載組件

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) 

我研究了錯誤,並試圖重新安裝按照Silverlight來this solution。但錯誤仍然發生。我看着this SO question,但我的App.xaml幾乎是242行。這裏是我的MainPage.xaml中大約線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> 

這裏是關於搜索窗口我試圖實例化的.xaml(大約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> 
+0

你能否在異常消息提到的行的周圍顯示XAML代碼:[Line:242 Position:46] – Spontifixus

+0

我已經提供了XAML代碼。 –

+0

哪條線是242? – Spontifixus

回答

1

的異常告訴

設置屬性 'System.Windows.FrameworkElement.Style' 引發了異常。

雖然這是不是您所顯示的代碼 - 但我幾乎可以肯定,你會發現像這樣的地方在你的代碼:

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

它應該是:

<SomeControl Style="{StaticResource MyCoolStyle}" ... />