Print Page | Close Window

LoginAsync. Allways returns error 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=2219
Printed Date: 16-Apr-2024 at 8:11am


Topic: LoginAsync. Allways returns error Call Connect() before doing a Login
Posted By: joão
Subject: LoginAsync. Allways returns error Call Connect() before doing a Login
Date 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:

http://drc.ideablade.com/xwiki/bin/view/Documentation/Code_ASPNETMembershipAndRoles - ASP.NET Membership and Roles
http://drc.ideablade.com/xwiki/bin/view/Documentation/Code_ASPNETMembershipWithRegistration - 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




Replies:
Posted By: sbelini
Date 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)


Posted By: sbelini
Date 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?


Posted By: joão
Date 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

 
 


Posted By: sbelini
Date 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).



Print Page | Close Window