Silverlight 5, return from WCF Ria Service, VB.NET - Simple Hello World

i can't found on any website (yeah.. i took a good couple or hours searching/Reading/testing), a way to call a simple Hello World Function by Return, and show it to the user.

Here is my WCF class code:

Imports System.ServiceModel
Imports System.ServiceModel.Activation

<ServiceContract(Namespace:="Servicio")>
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
Public Class ServicioBD

<OperationContract()>
Public Function ReturnString(ByVal number As Integer) As String

    If number = 1 Then
        Return "Hello World!"
    Else
        Return "Bye World!"
    End If

End Function

I added this service with the name "ServicioWCF_BD".

And this is how im calling it from the MainPage.xaml:

Private Sub SayHello()
Dim wcf As New ServicioWCF_BD.ServicioBDClient
    Dim message As String = wcf.ReturnStringAsync(1)  'ERROR THE EXPRESSION DOESNT GENERATE A VALUE
    MessageBox.Show(message)
End Sub

When i try to get the value from the function visual says the error: "The expression doesnt generate a value".

I hope you can help me, actually its the first time im stuck so hard with something that looks so simple..... * sigh *

Answers


The return value of wcf.ReturnStringAsync(1) is, most probably, of type Task and not string.

Your SayHello sub should look something like:

Private Sub SayHello()
    Dim wcf As New ServicioWCF_BD.ServicioBDClient
    Dim message As String = wcf.ReturnStringAsync(1).Result
    MessageBox.Show(message)
End Sub

Or, depending where you're calling it from:

Private Async Function SayHello() As Task
    Dim wcf As New ServicioWCF_BD.ServicioBDClient
    Dim message As String = Await wcf.ReturnStringAsync(1)
    MessageBox.Show(message)
End Sub

Need Your Help

PUT request with json content-type

php json put

I have a switch based on $_SERVER['REQUEST_METHOD'] and something is going wrong in the PUT case.

Using Pagination on product view using Category ID

php mysql pagination

I feel I have asked alot of questions recently and Im sorry if this is relatively simple but I am struggling to get this working correctly.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.