Print Page | Close Window

Call Connect() before doing a Login.

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2255
Printed Date: 29-Jul-2026 at 6:11am


Topic: Call Connect() before doing a Login.
Posted By: benmcneill
Subject: Call Connect() before doing a Login.
Date Posted: 23-Oct-2010 at 9:09pm
Hi Guys

I've read the other forum posts on this issue but just can't figure it out.

Several seconds after my app loads in Browser, I get "InvalidOperationException: Call Connect() before doing a Login".

Thing is, I am calling this. I have, in the Login() method upon Load:

private void Login()
{
       ILoginCredential credential = null;
       credential = new FormsAuthenticationLoginCredential("user", "password", "BENDESKTOP", true);

       EntityManager.ConnectAsync(op =>
       {
           EntityManager.LoginAsync(credential, LoginCompleted, null);
       });
}

If I completely remove the LoginAsync call, I still get told to Connect before logging in too. I had the app running fine for weeks, and all I did to change it was add a new project to the solution, so can't work out what's happening.

I originally had ConnectAsync and then LoginAsync separately (instead of LoginAsync call within ConnectAsync call) but the result was the same, as is to be expected I guess.

Anybody able to assist? Would be greatly appreciated. (I'm sure it's something simple).

Thanks in advance!

Cheers,
Ben



Replies:
Posted By: kimj
Date Posted: 24-Oct-2010 at 8:20am
The connect call is probably failing for some reason.  Check the op.Error returned by ConnectAsync to see what's going on.


Posted By: benmcneill
Date Posted: 25-Oct-2010 at 5:56am
Thanks,

Have tried below, but I get nothing. I tried the boolean haserror property also, but nothing, not even a message box. If I delete the entire Login Method, i still get the exception, even though LoginAsync isn't being called anywhere in the program. It's as if the whole method is being completely ignored but Login() is called upon Page_Loaded. Weird thing is, this error only started appearing after I added a new project to the solution. This didn't change the startup project or cause and inconsistencies either.

            private void Login()
            {
                ILoginCredential credential = null;
                credential = new FormsAuthenticationLoginCredential("user", "password", "BEN-NOTEBOOK", true);

                EntityManager.ConnectAsync(op =>
                {
                    var results = op.Error.Message;
                    MessageBox.Show(results.ToString());
                    EntityManager.LoginAsync(credential, LoginCompleted, null);
                });
            }


Posted By: benmcneill
Date Posted: 25-Oct-2010 at 6:11am
Ah....it wasn't rebuilding the xap and thus reading an old one...fixed now:)



Print Page | Close Window