New Posts New Posts RSS Feed: LoginAsync. Allways returns error Call Connect() before doing a Login
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

LoginAsync. Allways returns error Call Connect() before doing a Login

 Post Reply Post Reply
Author
joão View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Sep-2010
Location: Portugal
Posts: 5
Post Options Post Options   Quote joão Quote  Post ReplyReply Direct Link To This Post Topic: LoginAsync. Allways returns error Call Connect() before doing a Login
    Posted: 07-Oct-2010 at 2:26am

Hi everybody,

I' trying implement an authentication in my project. Every call to LoginAsync returns the error :

throw new Error("Unhandled Error in Silverlight 3 Application Call Connect() before doing a Login. em IdeaBlade.EntityModel.EntityManager.<LoginCoreAsync>b__8a(LoginOperation op)\n em IdeaBlade.EntityModel.AsyncProcessor`1.Execute()\n em IdeaBlade.EntityModel.EntityManager.<>c__DisplayClass8e.<LoginCoreAsync>b__8d()\n em IdeaBlade.EntityModel.EntityManager.DoAsyncAction(Action action)\n em IdeaBlade.EntityModel.EntityManager.LoginCoreAsync(AsyncProcessor`1 processor)\n em IdeaBlade.EntityModel.EntityManager.LoginAsync(ILoginCredential credential, Action`1 userCallback, Object userState)\n em AspAuthentication.LoginWindow.DoLogin()\n em AspAuthentication.LoginWindow.LoginButton_Click(Object sender, RoutedEventArgs e)\n em System.Windows.Controls.Primitives.ButtonBase.OnClick()\n em System.Windows.Controls.Button.OnClick()\n em System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)\n em System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)\n em MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)");
 
 
The most interesting is that i've downloaded the samples provided by IdeaBlade and this error also occurs in their projects:

ASP.NET Membership and Roles
ASP.NET Membership with Registration

I've read all documentation provided by ideablade and i can't find the cause neither a solution for this issue.

 I'm using:
 
DevStudio 2010
SilverLight 4
.Net Framwork 4
SqlServer 2008 R2
 
 

Is there any clues?
 
Thanks in advance

João Salgado

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 07-Oct-2010 at 3:29pm
Hi Joao,
 
in Page.xaml.cs where you have:
 
_entityManager.LoginAsync(credential, LoginCompleted, null);
 
try
 
_entityManager.ConnectAsync(op => {
  _entityManager.LoginAsync(credential, LoginCompleted, null);
});
 
instead.
 
Also, if you are using SQL Server, be sure to attach aspnetdb.mdf (included in the zip) to SQL Server. (as described in the Prerequisite section of the links you provided)
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 07-Oct-2010 at 4:13pm
Another detail I didn't mention in the previous post is that your error message says:
 
"Unhandled Error in Silverlight 3...
 
Can you check and make sure the target framework of your project is Silverlight 4?
Back to Top
joão View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Sep-2010
Location: Portugal
Posts: 5
Post Options Post Options   Quote joão Quote  Post ReplyReply Direct Link To This Post Posted: 08-Oct-2010 at 3:07am

hi sbelini

 
once again thank you for your prompt answer.
 
 
I've checked the target framework in my project and i confirm that is Silverlight 4
 
replacing
 
entityManager.LoginAsync(credential, LoginCompleted, null);
 
for
 
_entityManager.ConnectAsync(op => {
  _entityManager.LoginAsync(credential, LoginCompleted, null);
});
 
it worked well,
 
 
should i wrap every call to entitymanager with _entityManager.ConnectAsync(op => {
.SaveChangesAsync
.CancelAsync
.CancelCallback
.ExecuteQueryAsync
....
 
 
regards,
João Salgado
 

.SaveChangesAsync

 
 
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 08-Oct-2010 at 8:57am
The need to connect before a LoginAsync started on DevForce 6.0.5.
 
From the DevForce Release Notes:
 
"An “Implicit” connect is no longer performed on a disconnected EntityManager. If your Silverlight code relied on this behavior, you will have to change it to connect explicitly at the desired time.
This change was made to make working with a disconnected EntityManager more intuitive, and to align behavior between synchronous and asynchronous connection behaviors. A “connection” is the handshake which occurs between an EntityManager and an EntityServer before other requests are sent; usually the connection will occur during EntityManager construction, based on arguments passed, or later via an EntityManager.Connect or EntityManager.ConnectAsync call. [F1219/F1470]"
 
You normally need to ConnectAsync (or Connect) once only (unless you disconnect).
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down