我在任何网站上都找不到(是的..我花了几个或几个小时搜索/阅读/测试),这是一种通过 Return 调用简单的 Hello World 函数并将其展示给用户的方法。
这是我的 WCF 类代码:
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
我添加了这个名为“ServicioWCF_BD”的服务。
这就是我从 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
当我尝试从函数中获取值时,视觉显示错误:“表达式不生成值”。
我希望你能帮助我,实际上这是我第一次为看起来如此简单的事情如此努力...... *叹息*