So I made a simple service that allows Registrations and LogIns, so the only methods in my service contract are : Register(string username, string password) and LogIn(string username, string password). When starting the service in the Visual Studio service hosting gizmo I can call my methods properly and everything works well.
My problem is when I try to implement my service in an application. I kept it really simple, one form with fields for username and password for a login. I added a the service by going to Data -> Add New Data Source and gave my address from IIS (the service is hosted in IIS7). Here is a snipped of the would-be implementation code
public class LoginServiceClient
{
static LoginService.LoginClient client = new LoginClient();
public static bool LogIn(string username, string password)
{
string Username = username;
string HashedPassword = password; // No hash in place yet.
client.
return true;//Its *that* easy to get in my system.
}
}
Now the part that isn’t working is the line where I started typing “client.” expecting to find method names like LogIn and Register instead its LoginAsync and RegisterAsync. Both does not return anything therefore I cannot use them, neither are they offering callback methods.
What did I do wrong ? I can post more code if needed, from the service or details about implementation (as small as it is).
Worry not, you’ve done nothing wrong. The fact of the matter is that Silverlight requires many operations to be asynchronous; calling a WCF service (or making any sort of network request, for that matter) falls into that category of operations.
You’re going to want to look into consuming asynchronous patterns in the .NET Framework and Silverlight to get used to this new way of doing things. (Oh, and before you ask, Silverlight doesn’t support turning these into synchronous operations; you might have to restructure some of your code to work this way.)