开发者

silverlight application - server error not found

开发者 https://www.devze.com 2023-02-25 00:10 出处:网络
I was following a tutorial to create a silverlight web application that uses a datagrid and fetches data from a table but I keep getting the server error with just NotFound and no further details. Not

I was following a tutorial to create a silverlight web application that uses a datagrid and fetches data from a table but I keep getting the server error with just NotFound and no further details. Not sure how else to trace the error.

Imports System.ServiceModel
Imports System.ServiceModel.Activa开发者_运维百科tion

Public Class Service2

<OperationContract()>
Public Function DoWork() As List(Of RealTimeCount)
    Try
        Dim df As New DataClasses2DataContext
        Dim counts = (From record In df.RealTimePostCounts Order By record.pollDate, record.boxFeed, record.boxCount Select record)
        Dim list As New List(Of RealTimeCount)
        For Each d In counts
            list.Add(New RealTimeCount With {.getDate = d.pollDate, .boxItem = d.boxFeed, .boxSum = d.boxCount})
        Next

        Return list

    Catch ex As Exception....

 end try
 end function 
end class



Public Class MainPage
Inherits UserControl

Private WithEvents mservice As New ServiceReference1.Service2Client()


Public Sub New()
    InitializeComponent()
End Sub


Private Sub btnLoad_Click
  (ByVal sender As System.Object,
       ByVal e As System.Windows.RoutedEventArgs) Handles btnLoad.Click
    mservice.DoWorkAsync()

End Sub

Private Sub mservice_DoWorkCompleted
  (ByVal sender As Object, 
  ByVal e As ServiceReference1.DoWorkCompletedEventArgs) 
   Handles mservice.DoWorkCompleted
    DataGrid1.ItemsSource = e.Result
    DataGrid1.Visibility = Windows.Visibility.Visible
End Sub
 End Class


That error is extremely misleading and frustrating. When I run into it, I run fiddler2 (http://www.fiddler2.com), which captures the network traffic and will give you the exact reason for the failure. The most common issues I've seen are contract mismatches and client access policy errors.


Looks like you didn't add service to your silverlight application.
You can use WCF or WCF RIA services.
Here is tutorial which uses RIA service. It use DataGrid control and code is available for VB and C#.
Silverlight 3: Displaying SQL Server Data is other example which use WCF service to show data on DataGrid control.

Hope this will help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消