We are getting this error InvalidOperationException "userservice operation already in progress" in our Silverlight 4 (OOB with RIA Services) when you click the Login button, but it doesnt happen everytime and sometimes it happens multiple times. If I ignore the error and keep running it seems to work. Does anyone know what is causing this?
EDIT : The project was created using the "Silverlight Business Application" template.
Stack Trace
at System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationService.StartOperation(AuthenticationOperation operation)
at System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationService.Login(LoginParameters parameters, Action`1 completeAction, Object userState) at Reach.SL.LoginUI.LoginForm.LoginButton_Click(Object sender, EventArgs e) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at 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 (More Info). I have been able to reproduce the problem consistantly with a new 'Silverlight Business Application'开发者_开发问答 solution and a few minor changes. The problem happens a lot more out on site where the services are slower to respond, hence all of the changes are to speed up user input on my dev box. If you start with the 'Silverlight Business Application' and change it to do two things; 1. Show the login box as soon as it loads. 2. default in some valid credentials (so you dont have to type them).
Then run the app and press 'enter' (to login) as soon as the screen is displayed, then i get the error consistantly.
I have used Fiddler and it shows that there is two calls actually happening...
/ClientBin/SilverlightBusinessApp-Web-AuthenticationService.svc/binary/GetUser
/ClientBin/SilverlightBusinessApp-Web-AuthenticationService.svc/binary/Login
The error occurs when the first call to GetUser is still in progress when it calls the login. Where is this call to GetUser coming from? (is it getting credentials from the aspnetDB)
What code can i add so it doesnt call Login until the GetUser call is finished? ( i have tried "WebContext.Current.Authentication.IsBusy" but it does not seem to reset when the call to getUser is finished.
In the Silverlight Business Application template the following line of code can be found in App.xaml.cs in the Application_Startup method.
WebContext.Current.Authentication.LoadUser(this.Application_UserLoaded, null);
This line will cause a call to GetUser on your AuthenticationService (which also comes with the template). So essentially this GetUser service call is happening when the application is launched, which is what is causing the problem with users logging in quickly after launching the application.
If you don't want users to be automatically signed in if they check the "keep me logged in" field, then you can safely remove this line from Application_Startup. Another option is to create some kind of LoginHelper class and fire an event in that class when the login completes. Listen for this event on your login control and only enable the login button when the initial GetUser call completes.
There are several other potential work-arounds but without knowing the architecture of your project it's difficult to recommend one. Hope this helps.
加载中,请稍侯......
精彩评论