I'm using .Net Core 2.0 and VS 2017 v15.3.1. I'm trying to test making a Microsoft WCF Web Service Reference test by logging into a Salesforce service using SOAP. I successfully created the service reference using a WSDL. I've done this using .Net and have successfully logged in using a Service Reference (SoapClient) and a Web Service (SforceService). The interface created in .Net Core 2.0 is all asynchronous versus synchronous in .Net. I know little about async. I created a simple command line program to test the interface but I don't know async. I've done numerous versions of it. This is the latest attempt. I noted the error using a comment VS is giving me (red squiggly).
Any help is appreciated.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using SFDC;
namespace SfSoapCore
{
class Program
{
static string userName = "";
static string password = "";
static string securityToken = "";
static SoapClient sc;
static loginResponse lresp;
static LoginResult lres;
static LoginScopeHeader lsr = null;
static void Main(string[] args)
{
sc = new SoapClient();
Run();
}
static async void Run()
{
Task<loginResponse> loginTask = new Task<loginResponse>(SfLogin);
loginTask.Start();
lresp = await loginTask;
lres = lresp.result;
string serverUrl = lres.serverUrl;
string sessionId = lres.sessionId;
Console.WriteLine("Break");
}
static async loginResponse SfLogin() //ERROR 'return type of an async method must be void, Task or Task<T>'
{
loginResponse lr = await sc.loginAsync(null, userName, password + securityToken);
return lr;
}
}
}