2011-06-14 68 views
2

我有一个Silverlight应用程序,我遇到了问题。浏览器刷新时Silverlight页不加载

正常加载时 - 通过网络浏览器或将其安装到桌面时,页面工作良好。 问题出现在浏览器中,当有人点击刷新。

当它们点击刷新(F5)时,没有数据加载,控件呈现但数据绑定的数据是空的。 他们有一个JavaScript错误,它出现在IE的底部。

页面错误细节

消息:未处理的错误在 Silverlight应用程序上的 'System.Windows.Data.Binding' 提供值 投掷 异常。 [行:74的位置:57] 在 MS.Internal.XcpImports.MethodEx(IntPtr的 PTR,字符串名称,CValue [] cvData)
在 MS.Internal.XcpImports.MethodEx(DependencyObject的 OBJ,字符串名称)在 MS.Internal.XcpImports.DataTemplate_LoadContent(DataTemplate中 模板)在 System.Windows.Controls.DataGridTemplateColumn.GenerateElement(DataGridCell 细胞,对象的DataItem)在 System.Windows.Controls.DataGrid.PopulateCellContent(布尔 isCellEdited,的DataGridColumn dataGridColumn,DataGridRow dataGridRow,DataGridCell dataGridCell)在 System.Windows.Controls.DataGrid.AddNewCellPrivate(DataGridRow 行,列的DataGridColumn)在 System.Windows.Controls.DataGrid.CompleteCellsCollection(DataGridRow dataGridRow)在 System.Windows.Controls.DataGrid.GenerateRow( INT32 rowIndex位置,INT32槽,在 System.Windows.Controls.DataGrid.InsertElementAt(INT32 插槽,INT32 rowIndex位置,对象项目, DataGridRowGroupInfo GROUPINFO, 布尔isCollapsed)对象 的DataContext)在 System.Windows.Controls.DataGrid .InsertRowAt(Int32 rowIndex)at System.Windows.Controls.DataGridDataConnection。 NotifyingDataSource_CollectionChanged(对象 发件人, NotifyCollectionChangedEventArgs E)
在 System.Windows.Data.PagedCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs 参数)在 System.Windows.Data.PagedCollectionView.ProcessAddEvent(对象 addedItem,的Int32 addIndex)在 系统.Windows.Data.PagedCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)at System.Windows.Data.PagedCollectionView。 < .ctor> B_ 0(对象 发件人, NotifyCollectionChangedEventArgs参数) 在 System.Collections.ObjectModel.ObservableCollection在 System.Collections.ObjectModel.Collection`1 1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection 1.InsertItem(的Int32 索引,T项)。在 MyProject.Silverlight.MyViewModel.b _3(对象 帕拉姆,GetDataCompletedEventArgs EventArgs的)添加(T 项目)在 MyProject.Silverlight.WebServicesSVC.WebServicesClient。OnGetDataCompleted(对象 状态)行:1字符:1个代码:0

如果[行:74的位置:57]是从XAML文件,则误差是中间行:

<sdk:DataGridTemplateColumn Header="Edit Details"> 
    <sdk:DataGridTemplateColumn.CellTemplate> 
     <DataTemplate> 
      <Button Command="{Binding UpdateCommand, Source={StaticResource ViewModel}}" CommandParameter="{Binding}" Content="Update" /> 
     </DataTemplate> 
    </sdk:DataGridTemplateColumn.CellTemplate> 
</sdk:DataGridTemplateColumn> 

即,[Button ...]行,位置57是“{Binding ..}”在Command =中开始的位置。

- 正如我所说,这只发生在页面刷新使用IE的刷新按钮时,并且它发生在每台PC上。

其他细节: 的Internet Explorer 8 客户端电脑:Windows XP中 托管服务器:在Windows Server 2005(或2003,如果没有这样的东西作为2005年)。 Silverlight 4

任何人都可以阐明什么是错的?如何处理刷新与正常加载页面不同?

+0

刷新页面比第一次加载更快,因此它可能是一个计时问题。你的数据来自哪里?它是如何填充的? – 2011-06-14 15:52:35

+0

@jb我写了一个非常小的HelloWorld,看它是否是Silverlight正在做的特殊事情,事实并非如此。 F5确实能够正确地提供我的数据。是否有可能分享一些代码,以便我可以尝试重现该问题? – Nair 2011-06-14 17:59:03

+0

该页面由几个WCF服务填充;我在应用程序中有几个页面,只有其中一个失败(那个确实有4-5个服务调用将数据拉回的页面)。 – 2011-06-15 15:16:40

回答

0

当我在我的Silverlight项目的部署版本中收到javascript错误时,它几乎总是我后面的代码中的应用程序的逻辑问题。因人而异。

鉴于您有SL4,您可能无法在XAML中放置调试点。 我觉得在部署代码的另一个盒子上提到SL5测试版以获得该功能以帮助进行调试。

或者,你可以在软件刷新每:

Can Silverlight initiate Page Refreshes?

,然后看看你的应用程序的行为不同。