 |
BOOK: Silverlight 4 Problem - Design - Solution
 | This is the forum to discuss the Wrox book Silverlight 4 Problem - Design - Solution by Nick Lecrenski; ISBN: 9780470534045 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Silverlight 4 Problem - Design - Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 30th, 2010, 07:53 PM
|
|
Registered User
|
|
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Duplicate email on sign up - domain exception not passed to silverlight
I am working through the Silverlight 4 problem design solution book. I created the sign up form but in a child window instead of a separate page. It all works except when I attempt to sign up again with the same email address. I was expecting the results.haserror to return "Duplicate email" exception but it seems that silverlight just swallows that error. During debugging it breaks at a domain exception. Without debugging enabled it simply shows no error message.
Here is the createusercallback from the book... with some added try catch blocks
private void CreateUserCallback( InvokeOperation result)
{
if (!result.HasError)
{
// After successfully creating a new account you want the user to automatically be
// logged in and redirected to the Dashboard. By firing this custom SignupComplete
// event the parent control can perform the login operation when the account has been
// created.
try
{
if (SignupComplete != null)
{
SignupComplete(this, new SignupEventArgs(result.UserState as tuser));
}
else
{
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Registration Error Details", MessageBoxButton.OK);
}
///this.DialogResult = true;
}
else
{
MessageBox.Show(result.Error.Message.ToString(), "Registration Error Details", MessageBoxButton.OK);
result.MarkErrorAsHandled();
}
}
The domain service using a custom membership provider call
[EnableClientAccess()]
public class TUserService : LinqToSqlDomainService<UsersDataContext>
{
private NG.Web.Providers.MembershipProvider provider = Membership.Provider as NG.Web.Providers.MembershipProvider;
[Invoke]
public void CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer)
{
MembershipCreateStatus status;
tuser createUser = provider.CreateUser(username, password, email, passwordQuestion, passwordAnswer,
true, null, out status) as tuser;
if (status != MembershipCreateStatus.Success)
{
throw new DomainException(status.ToString());
}
}
public tuser GetUser(string email)
{
return provider.GetUser(email, true) as tuser;
}
}
I probably haven't shown enough info or the correct info... Any ideas?
|
|

November 1st, 2010, 02:04 PM
|
|
Registered User
|
|
Join Date: Oct 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
More info
I am now using a return function as follows... Still not working though!
[Invoke]
public CreateUserStatus CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer)
{
MembershipCreateStatus status;
tuser createUser = provider.CreateUser(username, password, email, passwordQuestion, passwordAnswer, true, null, out status) as tuser;
if (status != MembershipCreateStatus.Success)
{
return TUserService.ConvertStatus(status);
//throw new DomainException(status.ToString());
}
else
{
return TUserService.ConvertStatus(status);
}
}
|
|

November 1st, 2010, 07:03 PM
|
|
Authorized User
|
|
Join Date: Sep 2009
Posts: 34
Thanks: 4
Thanked 1 Time in 1 Post
|
|
Quote:
Originally Posted by Dannyd5
I am now using a return function as follows... Still not working though!
[Invoke]
public CreateUserStatus CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer)
{
MembershipCreateStatus status;
tuser createUser = provider.CreateUser(username, password, email, passwordQuestion, passwordAnswer, true, null, out status) as tuser;
if (status != MembershipCreateStatus.Success)
{
return TUserService.ConvertStatus(status);
//throw new DomainException(status.ToString());
}
else
{
return TUserService.ConvertStatus(status);
}
}
|
I think, the error is in the client side code.
In the latest server side code You return the same object independently of the status value.
Try to omit the Try Catch block in the client code.
Gabor
|
|
 |
|