missing exception

missing exception

Old forum URL: forums.lhotka.net/forums/t/6686.aspx


davido posted on Friday, March 27, 2009

I have an exception occuring on my server side but I don't know how to get the exception on the client side. The code on the client side looks like that shown below:

FieldSalesActivityPrincipal.Login(domain, logon, (o1, e1) =>

{

animation.IsRunning = false;

if (Csla.ApplicationContext.User.Identity.IsAuthenticated)

{

Status.Text = "Login Successfull.";

if (LoginSuccessfull != null)

LoginSuccessfull.Invoke(this, EventArgs.Empty);

}

else

{

if (string.IsNullOrEmpty(Csla.ApplicationContext.User.Identity.Name))

{

Status.Text = "null or em";

}

else

{

Status.Text = Csla.ApplicationContext.User.Identity.Name; //"Not an application user.";

}

}

}

);

 

Csla.ApplicationContext.User.Identity.Name is coming back as null or empty. I can see from the W3C log files that I get an HTTP 200 when an attempt is made to access the WcfPortal.svc

Any help appreciated.

RockfordLhotka replied on Friday, March 27, 2009

In your callback handler (inside the lambda) you need to check e1.Error to see if it is not null:

  if (e1.Error != null)
  {
    // process server-side exception
  }
  else
  {
    // process e1.Object result, probably making it the current principal
    Csla.ApplicationContext.User = e1.Object;
  }

 

davido replied on Friday, March 27, 2009

Thanks for reply. e1 does not have a .Error property as the previous code calls the code shown below (I should have shown this earlier):

 

#if SILVERLIGHT

public static void Login(string domain, string logon, EventHandler<EventArgs> completed)

{

FieldSalesActivityIdentity.GetIdentity(domain, logon, (o, e) =>

{

if (e.Object == null)

{

SetPrincipal(FieldSalesActivityIdentity.UnauthenticatedIdentity());

}

else

{

SetPrincipal(e.Object);

}

completed(null, EventArgs.Empty);

});

}

#else

Which returns with

completed(null, EventArgs.Empty);

Should I derive from System.EventArgs or is there a Csla EventArgs class I can use?

 

RockfordLhotka replied on Friday, March 27, 2009

Still, all this means is that your GetIdentity() method’s callback handler needs to check e.Error.

 

The principal is the same – at some point you call the data portal, and the data portal will return the server-side error (if any) through the e.Error value. You must check that value before attempting to use e.Object.

 

Rocky

Copyright (c) Marimer LLC