We get this InvalidOperationException error "working with a user service that is already running" in our Silverlight 4 (OOB with RIA services) when you click the "Login" button, but this does not happen every time, and sometimes several times. If I ignore the error and keep working, it seems to work. Does anyone know what causes this?
EDIT: The project was created using the Silverlight business application template.
Stack trace
in System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationService.StartOperation (authentication operation)
in System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationService.Login (parameters LoginParameters, Action`1 completeAction, Object userState)
in Reach.SL.LoginUI.LoginForm.LoginButton_Click (object sender, EventArgs e)
in System.Windows.Controls.Primitives.ButtonBase.OnClick () in System.Windows.Controls.Button.OnClick () in System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp (MouseButtonEventArgs e)
in System.Windows.Controls.Control.OnMouseLeftButtonUp (Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent (IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
EDIT (additional information). I was able to consistently reproduce the issue with the new Silverlight Business Application solution and a few minor changes. The problem arises much more on a site where services respond more slowly, so all the changes are faster user input in my dev block. If you start with the Silverlight Business Application and change it to do two things; 1. Show the registration window as soon as it loads. 2. default in some valid credentials (so you do not need to enter them).
Then run the application and press 'enter' (to enter the system) as soon as the screen is displayed, then I will get the error sequentially.
I used Fiddler and it shows that two calls are actually happening ...
/ClientBin/SilverlightBusinessApp-Web-AuthenticationService.svc/binary/GetUser /ClientBin/SilverlightBusinessApp-Web-AuthenticationService.svc/binary/Login
The error occurs when the first GetUser call is still made when it calls the login. Where does this call from GetUser come from? (this is getting credentials from aspnetDB)
What code can be added so that it does not call Login until the GetUser call is completed? (I tried "WebContext.Current.Authentication.IsBusy", but it does not seem to reset when the getUser call is complete.