-
-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xamarin: ApplicationContext.User not persisting during Async call #1010
Comments
You have a reference to the CSLA-ASP.NET NuGet package? |
btw, for faster response to this sort of question in the future, please post in the CSLA .NET forum instead of in the main repo. A lot of people watch the forum, this repo's issues are typically only checked when I'm grooming the backlog. |
I have it referenced in my App Server but not in my Business Library, and my App PCL. When I try to reference it I get the following error:
The same error is Replicated for my iOS project, except the incompatibility is now between CSLA-ASP.NET 4.8.1 and xamarinios10. Also, thanks for the tip. |
I was only referring to the server project. It isn't surprising that ASP.NET code is incompatible with Xamarin. On the client side you need to make sure to reference CSLA-Xamarin. The reason I asked about the server, is that proper handling of the |
I see. CSLA-XamarinForms is referenced in all of my UI projects. |
I believe we are having the same problem with one of our applications. I believe the root cause to be something having changed with Xamarin. I am inclined to believe this as:
Further on this point, I must also set the Linker Behavior (iOS app properties -> iOS Build) to "Don't Link" otherwise |
@MTantos Have you tried to upgrade to .NET 4.7.2? There were a few Xamarin related fixes in the update from Microsoft. |
@JamesJohn93 No I haven't. I am sceptical that this will solve my problem as the server is working fine; running .NET 4.6.1. The client, using XamarinForms (.netstandard 2.0.3), and Xamarin (iOS 12.1) is where the issue lies. In the following code blocks (which run on the client), the identity is correctly returned from the server, but the client fails to set Csla.ApplicationContext.User on the worker thread and retrieve it again on the Main Thread. Principal
Calling Code
If I replace
With all that being said; I'll try updating my server to .NET 4.7.2 and report back if that does indeed solve my issue. |
As a temporary work around I have found the following to work. Define the following class
And then in App.xaml.cs
|
It appears that CSLA isn't properly loading the appropriate context manager from I encountered this a couple weeks ago, but in a solution with WebAssembly as well as Xamarin, and I blamed it on the wasm project in the solution. Perhaps there really is something preventing CSLA from auto-detecting and loading the context manager from |
Resolved by #1043 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description of the Issue
During an async call I am getting an UnauthenticatedPrincipal whenever I try to use Csla.ApplicationContext.User set to Csla.Principal to Check if a user is authenticated even though I have set it just after authenticating the user.
Version and Platform
CSLA version: 4.8.1
OS: Windows.
Platform: ASP.NET Standard 2.0, Xamarin Forms, Android. IOS.
Code that Fails
Failure occurs in the Business Object when I try to retrieve any data.
Login Command
AuthenticationService.Authenticate Method called in the LoginCommand
LoginAsync Method called in Authenticate Method
Getting UserIdentity and Setting ApplicationContext.User
Home Screen Init Method Where Failure occurs
AddCommentToInfo Method
Exception Detail and Additional Context
Even If I try to use the Csla.ApplicationContext.User elsewhere in the Home Screen View Model, I still get an UnauthenticatedPrincipal as seen in the AddToComment(). Csla.ApplicationContext.User.Identity.Name is null.
The text was updated successfully, but these errors were encountered: