2011-11-13 30 views
1

當我收到的Visual Studio剛剛在實時調試錯誤 未處理的異常(「未處理的錯誤在Silverlight應用程序 代碼:4004 類別:MangedRuntimeError 消息:System.ServiceMode.DomainServices.Client .DomainOperationException:收到RunTimeError使用LoadOperation

一旦我裝載一行代碼作爲

Public Sub New() 
InitializeComponent() 
Dim context As New OrganizationContext() 
context.Load(context.GetTimeTablesQuery(), AddressOf LoadMonday, Nothing) 

End Sub 

Private Sub LoadMonday(ByVal obj As LoadOperation(Of TimeTable)) 

Dim btnMonday(20) As Button 
For a As Integer = 0 To 19 
      btnMonday(a) = New Button() 
      btnMonday(a).Height = 23 
      btnMonday(a).Width = 107 
      btnMonday(a).Content = timeslot(a) 
      btnMonday(a).Background = New SolidColorBrush(Colors.Magenta) 

      ' Sets dependency properties 
      btnMonday(a).SetValue(Grid.ColumnProperty, 1) 
      btnMonday(a).SetValue(Grid.RowProperty, a + 1) 
      LayoutRoot.Children.Add(btnMonday(a)) 
     Next 
End Sub 

任何想法

回答

0

你可以通過檢查它的HasError屬性來檢查你的obj是否有錯誤。如果LoadOperation HasError是真的,你可以撥打MarkErrorAsHandled

示例代碼:

' if there is an error, mark is as handled. 
If (obj.HasError) Then 
    obj.MarkErrorAsHandled() 
End If 
+0

THX非常多。它解決了我的問題。 –

+0

其實笏問題是? 雖然它解決了這個問題。我能知道爲什麼會彈出這個問題嗎? –

+0

obj.Error屬性具有錯誤的詳細信息。 http://msdn.microsoft.com/en-us/library/system.servicemodel.domainservices.client.operationbase.error(v = VS.91).aspx – Ekk